From 3bed560644d3f2972ad40d670255dc17099f9a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Wed, 10 Oct 2018 19:22:37 +0200 Subject: [PATCH 01/28] added solver containing Steger-Warming, Van Leer and Lax Friedrich in one for Euler and Navier-Stokes --- src/Examples/CMakeLists.txt | 12 +- .../flow-sw/navierStokesBuildConfigTag.h | 14 + .../flow-vl/navierStokesBuildConfigTag.h | 14 + .../Boiler/BoundaryConditionsBoiler.h | 137 ++ .../CompressibleConservativeVariables.h | 147 ++ .../Boiler/DensityBoundaryConditionBoiler.h | 542 +++++++ .../Boiler/EnergyBoundaryConditionBoiler.h | 854 ++++++++++ .../Boiler/MomentumXBoundaryConditionBoiler.h | 594 +++++++ .../Boiler/MomentumYBoundaryConditionBoiler.h | 588 +++++++ .../Boiler/MomentumZBoundaryConditionBoiler.h | 563 +++++++ .../Cavity/BoundaryConditionsCavity.h | 137 ++ .../CompressibleConservativeVariables.h | 147 ++ .../Cavity/DensityBoundaryConditionCavity.h | 536 +++++++ .../Cavity/EnergyBoundaryConditionCavity.h | 673 ++++++++ .../Cavity/MomentumXBoundaryConditionCavity.h | 570 +++++++ .../Cavity/MomentumYBoundaryConditionCavity.h | 564 +++++++ .../Cavity/MomentumZBoundaryConditionCavity.h | 554 +++++++ src/Examples/flows/CMakeLists.txt | 53 + .../flows/CompressibleConservativeVariables.h | 147 ++ .../Euler/Lax-Friedrichs/LaxFridrichs.h | 149 ++ .../Lax-Friedrichs/LaxFridrichsContinuity.h | 288 ++++ .../Euler/Lax-Friedrichs/LaxFridrichsEnergy.h | 309 ++++ .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 68 + .../Lax-Friedrichs/LaxFridrichsMomentumX.h | 276 ++++ .../Lax-Friedrichs/LaxFridrichsMomentumY.h | 260 +++ .../Lax-Friedrichs/LaxFridrichsMomentumZ.h | 240 +++ .../Euler/Steger-Warming/StegerWarming.h | 151 ++ .../Steger-Warming/StegerWarmingContinuity.h | 381 +++++ .../Steger-Warming/StegerWarmingEnergy.h | 540 +++++++ .../StegerWarmingMomentumBase.h | 130 ++ .../Steger-Warming/StegerWarmingMomentumX.h | 342 ++++ .../Steger-Warming/StegerWarmingMomentumY.h | 318 ++++ .../Steger-Warming/StegerWarmingMomentumZ.h | 276 ++++ .../Euler/VanLeer/VanLeer.h | 151 ++ .../Euler/VanLeer/VanLeerContinuity.h | 382 +++++ .../Euler/VanLeer/VanLeerEnergy.h | 504 ++++++ .../Euler/VanLeer/VanLeerMomentumBase.h | 122 ++ .../Euler/VanLeer/VanLeerMomentumX.h | 342 ++++ .../Euler/VanLeer/VanLeerMomentumY.h | 318 ++++ .../Euler/VanLeer/VanLeerMomentumZ.h | 276 ++++ .../Lax-Friedrichs/LaxFridrichs.h | 156 ++ .../Lax-Friedrichs/LaxFridrichsContinuity.h | 290 ++++ .../Lax-Friedrichs/LaxFridrichsEnergy.h | 518 ++++++ .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 73 + .../Lax-Friedrichs/LaxFridrichsMomentumX.h | 383 +++++ .../Lax-Friedrichs/LaxFridrichsMomentumY.h | 363 +++++ .../Lax-Friedrichs/LaxFridrichsMomentumZ.h | 314 ++++ .../Steger-Warming/StegerWarming.h | 158 ++ .../Steger-Warming/StegerWarmingContinuity.h | 386 +++++ .../Steger-Warming/StegerWarmingEnergy.h | 717 +++++++++ .../StegerWarmingMomentumBase.h | 137 ++ .../Steger-Warming/StegerWarmingMomentumX.h | 433 +++++ .../Steger-Warming/StegerWarmingMomentumY.h | 403 +++++ .../Steger-Warming/StegerWarmingMomentumZ.h | 338 ++++ .../Navier-Stokes/VanLeer/VanLeer.h | 158 ++ .../Navier-Stokes/VanLeer/VanLeerContinuity.h | 382 +++++ .../Navier-Stokes/VanLeer/VanLeerEnergy.h | 681 ++++++++ .../VanLeer/VanLeerMomentumBase.h | 129 ++ .../Navier-Stokes/VanLeer/VanLeerMomentumX.h | 433 +++++ .../Navier-Stokes/VanLeer/VanLeerMomentumY.h | 403 +++++ .../Navier-Stokes/VanLeer/VanLeerMomentumZ.h | 338 ++++ src/Examples/flows/PhysicalVariablesGetter.h | 122 ++ .../flows/RiemannProblemInitialCondition.h | 1417 +++++++++++++++++ src/Examples/flows/euler.cpp | 1 + src/Examples/flows/euler.cu | 1 + src/Examples/flows/euler.h | 134 ++ src/Examples/flows/eulerProblem.h | 118 ++ src/Examples/flows/eulerProblem_impl.h | 416 +++++ src/Examples/flows/flowsBuildConfigTag.h | 72 + src/Examples/flows/flowsRhs.h | 35 + src/Examples/flows/navierStokes.cpp | 1 + src/Examples/flows/navierStokes.cu | 1 + src/Examples/flows/navierStokes.h | 122 ++ src/Examples/flows/navierStokesProblem.h | 121 ++ src/Examples/flows/navierStokesProblem_impl.h | 439 +++++ src/Examples/flows/run-euler | 25 + src/Examples/flows/run-navier-stokes | 25 + src/Examples/inviscid-flow-sw/eulerProblem.h | 9 +- .../inviscid-flow-sw/eulerProblem_impl.h | 136 +- .../inviscid-flow-vl/eulerBuildConfigTag.h | 16 +- .../inviscid-flow/eulerBuildConfigTag.h | 12 + .../transportEquationProblem.h | 2 +- 82 files changed, 22996 insertions(+), 91 deletions(-) create mode 100644 src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h create mode 100644 src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h create mode 100644 src/Examples/flows/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h create mode 100644 src/Examples/flows/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h create mode 100644 src/Examples/flows/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h create mode 100644 src/Examples/flows/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h create mode 100644 src/Examples/flows/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h create mode 100644 src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h create mode 100644 src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h create mode 100644 src/Examples/flows/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h create mode 100644 src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h create mode 100644 src/Examples/flows/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h create mode 100644 src/Examples/flows/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h create mode 100644 src/Examples/flows/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h create mode 100644 src/Examples/flows/CMakeLists.txt create mode 100644 src/Examples/flows/CompressibleConservativeVariables.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h create mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h create mode 100644 src/Examples/flows/PhysicalVariablesGetter.h create mode 100644 src/Examples/flows/RiemannProblemInitialCondition.h create mode 100644 src/Examples/flows/euler.cpp create mode 100644 src/Examples/flows/euler.cu create mode 100644 src/Examples/flows/euler.h create mode 100644 src/Examples/flows/eulerProblem.h create mode 100644 src/Examples/flows/eulerProblem_impl.h create mode 100644 src/Examples/flows/flowsBuildConfigTag.h create mode 100644 src/Examples/flows/flowsRhs.h create mode 100644 src/Examples/flows/navierStokes.cpp create mode 100644 src/Examples/flows/navierStokes.cu create mode 100644 src/Examples/flows/navierStokes.h create mode 100644 src/Examples/flows/navierStokesProblem.h create mode 100644 src/Examples/flows/navierStokesProblem_impl.h create mode 100644 src/Examples/flows/run-euler create mode 100644 src/Examples/flows/run-navier-stokes diff --git a/src/Examples/CMakeLists.txt b/src/Examples/CMakeLists.txt index 2d46b2446..a132af7bd 100644 --- a/src/Examples/CMakeLists.txt +++ b/src/Examples/CMakeLists.txt @@ -3,14 +3,12 @@ ADD_SUBDIRECTORY( Containers ) add_subdirectory( simple-examples ) add_subdirectory( heat-equation ) add_subdirectory( transport-equation ) -add_subdirectory( navier-stokes ) -add_subdirectory( inviscid-flow ) -add_subdirectory( inviscid-flow-sw ) -add_subdirectory( inviscid-flow-vl ) +#add_subdirectory( navier-stokes ) +#add_subdirectory( inviscid-flow ) +#add_subdirectory( inviscid-flow-sw ) +#add_subdirectory( inviscid-flow-vl ) #add_subdirectory( mean-curvature-flow ) -add_subdirectory( flow ) -add_subdirectory( flow-sw ) -add_subdirectory( flow-vl ) +add_subdirectory( flows ) ADD_EXECUTABLE( ConfigDescriptionExample ConfigDescriptionExample.cpp ) diff --git a/src/Examples/flow-sw/navierStokesBuildConfigTag.h b/src/Examples/flow-sw/navierStokesBuildConfigTag.h index 9267843d5..78e8c57c3 100644 --- a/src/Examples/flow-sw/navierStokesBuildConfigTag.h +++ b/src/Examples/flow-sw/navierStokesBuildConfigTag.h @@ -21,6 +21,20 @@ template<> struct ConfigTagReal< navierStokesBuildConfigTag, long double > { enu template<> struct ConfigTagIndex< navierStokesBuildConfigTag, short int >{ enum { enabled = false }; }; template<> struct ConfigTagIndex< navierStokesBuildConfigTag, long int >{ enum { enabled = false }; }; +//template< int Dimension > struct ConfigTagDimension< navierStokesBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; + +/**** + * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. + */ +/* +template< int Dimension, typename Real, typename Device, typename Index > + struct ConfigTagMesh< navierStokesBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > + { enum { enabled = ConfigTagDimension< navierStokesBuildConfigTag, Dimension >::enabled && + ConfigTagReal< navierStokesBuildConfigTag, Real >::enabled && + ConfigTagDevice< navierStokesBuildConfigTag, Device >::enabled && + ConfigTagIndex< navierStokesBuildConfigTag, Index >::enabled }; }; +*/ + /**** * Please, chose your preferred time discretisation here. */ diff --git a/src/Examples/flow-vl/navierStokesBuildConfigTag.h b/src/Examples/flow-vl/navierStokesBuildConfigTag.h index 9267843d5..78e8c57c3 100644 --- a/src/Examples/flow-vl/navierStokesBuildConfigTag.h +++ b/src/Examples/flow-vl/navierStokesBuildConfigTag.h @@ -21,6 +21,20 @@ template<> struct ConfigTagReal< navierStokesBuildConfigTag, long double > { enu template<> struct ConfigTagIndex< navierStokesBuildConfigTag, short int >{ enum { enabled = false }; }; template<> struct ConfigTagIndex< navierStokesBuildConfigTag, long int >{ enum { enabled = false }; }; +//template< int Dimension > struct ConfigTagDimension< navierStokesBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; + +/**** + * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. + */ +/* +template< int Dimension, typename Real, typename Device, typename Index > + struct ConfigTagMesh< navierStokesBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > + { enum { enabled = ConfigTagDimension< navierStokesBuildConfigTag, Dimension >::enabled && + ConfigTagReal< navierStokesBuildConfigTag, Real >::enabled && + ConfigTagDevice< navierStokesBuildConfigTag, Device >::enabled && + ConfigTagIndex< navierStokesBuildConfigTag, Index >::enabled }; }; +*/ + /**** * Please, chose your preferred time discretisation here. */ diff --git a/src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h new file mode 100644 index 000000000..0cba68d7f --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h @@ -0,0 +1,137 @@ +#include + +#include "DensityBoundaryConditionBoiler.h" +#include "MomentumXBoundaryConditionBoiler.h" +#include "MomentumYBoundaryConditionBoiler.h" +#include "MomentumZBoundaryConditionBoiler.h" +#include "EnergyBoundaryConditionBoiler.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsBoiler +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshType > MeshPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h b/src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h new file mode 100644 index 000000000..a3afc8453 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h @@ -0,0 +1,147 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshType > MeshPointer; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + MeshFunctionPointer& getDensity() + { + return this->density; + } + + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /*MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TN \ No newline at end of file diff --git a/src/Examples/flows/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h new file mode 100644 index 000000000..c3bae7e3d --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h @@ -0,0 +1,542 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().y() < 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().z() < 0.8 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionBoilers: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h new file mode 100644 index 000000000..fe227d68f --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h @@ -0,0 +1,854 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + + + this->cavitySpeed + * + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) +{ + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * + ( + ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( + this->cavitySpeed + * + this->cavitySpeed + ) + ); + + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h new file mode 100644 index 000000000..823ec475a --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h @@ -0,0 +1,594 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h new file mode 100644 index 000000000..76f3ff057 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h @@ -0,0 +1,588 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h new file mode 100644 index 000000000..188aaa985 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h @@ -0,0 +1,563 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h new file mode 100644 index 000000000..8a42faea1 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h @@ -0,0 +1,137 @@ +#include + +#include "DensityBoundaryConditionCavity.h" +#include "MomentumXBoundaryConditionCavity.h" +#include "MomentumYBoundaryConditionCavity.h" +#include "MomentumZBoundaryConditionCavity.h" +#include "EnergyBoundaryConditionCavity.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsCavity +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshType > MeshPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h b/src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h new file mode 100644 index 000000000..a3afc8453 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h @@ -0,0 +1,147 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshType > MeshPointer; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + MeshFunctionPointer& getDensity() + { + return this->density; + } + + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /*MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TN \ No newline at end of file diff --git a/src/Examples/flows/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h new file mode 100644 index 000000000..06515a88c --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h @@ -0,0 +1,536 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 1, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 1 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h new file mode 100644 index 000000000..74ea75a70 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h @@ -0,0 +1,673 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< 1, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< -1, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + ); + } + if( entity.getCoordinates().y() == 0 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 1 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + ); + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, -1 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + * ( + this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + * + this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + ( this->cavitySpeed + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 ) + ) + * + ( this->cavitySpeed + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 ) + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h new file mode 100644 index 000000000..b78731382 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h @@ -0,0 +1,570 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + * ( + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + ); + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h new file mode 100644 index 000000000..afce8239b --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h @@ -0,0 +1,564 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h new file mode 100644 index 000000000..1942cd589 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h @@ -0,0 +1,554 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/CMakeLists.txt b/src/Examples/flows/CMakeLists.txt new file mode 100644 index 000000000..866861d52 --- /dev/null +++ b/src/Examples/flows/CMakeLists.txt @@ -0,0 +1,53 @@ +#euler + +set( tnl_inviscid_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_inviscid_flow_SOURCES + euler.cpp + euler.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-euler euler.cu) + target_link_libraries (tnl-euler tnl ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-euler euler.cpp) + target_link_libraries (tnl-euler tnl ) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-euler + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-euler + ${tnl_inviscid_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/inviscid-flow ) + +#navier-stokes + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokes.cpp + navierStokes.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cu) + target_link_libraries (tnl-navier-stokes tnl ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cpp) + target_link_libraries (tnl-navier-stokes tnl ) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-euler + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/flows/CompressibleConservativeVariables.h b/src/Examples/flows/CompressibleConservativeVariables.h new file mode 100644 index 000000000..a3afc8453 --- /dev/null +++ b/src/Examples/flows/CompressibleConservativeVariables.h @@ -0,0 +1,147 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshType > MeshPointer; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + MeshFunctionPointer& getDensity() + { + return this->density; + } + + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /*MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TN \ No newline at end of file diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h new file mode 100644 index 000000000..ec17a98ae --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h @@ -0,0 +1,149 @@ +/*************************************************************************** + LaxFridrichs.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "LaxFridrichsContinuity.h" +#include "LaxFridrichsEnergy.h" +#include "LaxFridrichsMomentumX.h" +#include "LaxFridrichsMomentumY.h" +#include "LaxFridrichsMomentumZ.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichs +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef LaxFridrichsContinuity< Mesh, Real, Index > ContinuityOperatorType; + typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; + typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; + typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; + typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; + + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VectorFieldType > VectorFieldPointer; + typedef SharedPointer< MeshType > MeshPointer; + + typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); + } + + LaxFridrichs() + : artificialViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); + this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + + RealType artificialViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h new file mode 100644 index 000000000..45ad4d52b --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h @@ -0,0 +1,288 @@ +/*************************************************************************** + LaxFridrichsContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + LaxFridrichsContinuityBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + RealType artificialViscosity; +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h new file mode 100644 index 000000000..18c824762 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -0,0 +1,309 @@ +/*************************************************************************** + LaxFridrichsEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + LaxFridrichsEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) + - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east + - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse; + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse + + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) + -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h new file mode 100644 index 000000000..67dae9fdf --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -0,0 +1,68 @@ +/*************************************************************************** + LaxFridrichsMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + LaxFridrichsMomentumBase() + : artificialViscosity( 1.0 ){}; + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h new file mode 100644 index 000000000..63def12d3 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h @@ -0,0 +1,276 @@ +/*************************************************************************** + LaxFridrichsMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) + - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + //const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + //const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + //const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + //const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_u[ up ] * velocity_z_up ) + - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h new file mode 100644 index 000000000..8ce42282d --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h @@ -0,0 +1,260 @@ +/*************************************************************************** + LaxFridrichsMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse + + ( ( rho_v[ up ] * velocity_z_up ) + - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h new file mode 100644 index 000000000..a67e862ce --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h @@ -0,0 +1,240 @@ +/*************************************************************************** + LaxFridrichsMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) + -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) + - ( rho_w[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_w[ north ] * velocity_y_north ) + - ( rho_w[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) + - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h new file mode 100644 index 000000000..6083bbcd0 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h @@ -0,0 +1,151 @@ +/*************************************************************************** + StegerWarming.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "StegerWarmingContinuity.h" +#include "StegerWarmingEnergy.h" +#include "StegerWarmingMomentumX.h" +#include "StegerWarmingMomentumY.h" +#include "StegerWarmingMomentumZ.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarming +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef StegerWarmingContinuity< Mesh, Real, Index > ContinuityOperatorType; + typedef StegerWarmingMomentumX< Mesh, Real, Index > MomentumXOperatorType; + typedef StegerWarmingMomentumY< Mesh, Real, Index > MomentumYOperatorType; + typedef StegerWarmingMomentumZ< Mesh, Real, Index > MomentumZOperatorType; + typedef StegerWarmingEnergy< Mesh, Real, Index > EnergyOperatorType; + + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VectorFieldType > VectorFieldPointer; + typedef SharedPointer< MeshType > MeshPointer; + + typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + StegerWarming() + : artificialViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + + RealType artificialViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h new file mode 100644 index 000000000..105a6e432 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h @@ -0,0 +1,381 @@ +/*************************************************************************** + StegerWarmingContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + static String getType() + { + return String( "StegerWarmingContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h new file mode 100644 index 000000000..912b0156c --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h @@ -0,0 +1,540 @@ +/*************************************************************************** + StegerWarmingEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + StegerWarmingEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "StegerWarmingEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h new file mode 100644 index 000000000..31009af23 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h @@ -0,0 +1,130 @@ +/*************************************************************************** + StegerWarmingMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber + 1.0 ) * ( machNumber + 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber + 1.0 ) * (machNumber + 1.0 ) ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber - 1.0 ) * (machNumber - 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber - 1.0 ) * ( machNumber - 1.0 ) ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h new file mode 100644 index 000000000..36f71ce84 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h @@ -0,0 +1,342 @@ +/*************************************************************************** + StegerWarmingMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h new file mode 100644 index 000000000..4c03ba324 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h @@ -0,0 +1,318 @@ +/*************************************************************************** + StegerWarmingMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h new file mode 100644 index 000000000..9fe6b4123 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h @@ -0,0 +1,276 @@ +/*************************************************************************** + StegerWarmingMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h new file mode 100644 index 000000000..4c3d6112a --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h @@ -0,0 +1,151 @@ +/*************************************************************************** + VanLeer.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "VanLeerContinuity.h" +#include "VanLeerEnergy.h" +#include "VanLeerMomentumX.h" +#include "VanLeerMomentumY.h" +#include "VanLeerMomentumZ.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeer +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef VanLeerContinuity< Mesh, Real, Index > ContinuityOperatorType; + typedef VanLeerMomentumX< Mesh, Real, Index > MomentumXOperatorType; + typedef VanLeerMomentumY< Mesh, Real, Index > MomentumYOperatorType; + typedef VanLeerMomentumZ< Mesh, Real, Index > MomentumZOperatorType; + typedef VanLeerEnergy< Mesh, Real, Index > EnergyOperatorType; + + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VectorFieldType > VectorFieldPointer; + typedef SharedPointer< MeshType > MeshPointer; + + typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + VanLeer() + : artificialViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + + RealType artificialViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h new file mode 100644 index 000000000..2c8217465 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h @@ -0,0 +1,382 @@ +/*************************************************************************** + VanLeerContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + static String getType() + { + return String( "VanLeerContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + RealType multiply (const RealType& a, const RealType& b ) const + { + return a * b; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h new file mode 100644 index 000000000..2f0daead3 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h @@ -0,0 +1,504 @@ +/*************************************************************************** + VanLeerEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + VanLeerEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "VanLeerEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h new file mode 100644 index 000000000..5cc23112f --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h @@ -0,0 +1,122 @@ +/*************************************************************************** + VanLeerMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * ( - 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h new file mode 100644 index 000000000..948e8349b --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h @@ -0,0 +1,342 @@ +/*************************************************************************** + VanLeerMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h new file mode 100644 index 000000000..c8483e075 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h @@ -0,0 +1,318 @@ +/*************************************************************************** + VanLeerMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h new file mode 100644 index 000000000..6ea3da270 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h @@ -0,0 +1,276 @@ +/*************************************************************************** + VanLeerMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h new file mode 100644 index 000000000..1e119661c --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h @@ -0,0 +1,156 @@ +/*************************************************************************** + LaxFridrichs.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "LaxFridrichsContinuity.h" +#include "LaxFridrichsEnergy.h" +#include "LaxFridrichsMomentumX.h" +#include "LaxFridrichsMomentumY.h" +#include "LaxFridrichsMomentumZ.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichs +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef LaxFridrichsContinuity< Mesh, Real, Index > ContinuityOperatorType; + typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; + typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; + typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; + typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; + + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VectorFieldType > VectorFieldPointer; + typedef SharedPointer< MeshType > MeshPointer; + + typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + LaxFridrichs() + : artificialViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); + this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + + RealType artificialViscosity; + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h new file mode 100644 index 000000000..d821224f1 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h @@ -0,0 +1,290 @@ +/*************************************************************************** + LaxFridrichsContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + LaxFridrichsContinuityBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + RealType artificialViscosity; +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; +// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) +// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h new file mode 100644 index 000000000..e7cdd91be --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -0,0 +1,518 @@ +/*************************************************************************** + LaxFridrichsEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + LaxFridrichsEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) + - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east + - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse +// 1D uT_11_x + - 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse / 4 + * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ) +// 2D uT_11_x + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// vT_21_x + + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east + - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west + - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_12_y + + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south + - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south + - velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 2D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse + + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) + -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ) +// 3D uT_11_x + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east + - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// vT_21_x + + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east + - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west + - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// wT_31_x + + ( ( velocity_z_upEast * velocity_z_east - velocity_z_downEast * velocity_z_east + - velocity_z_upWest * velocity_z_west + velocity_z_downWest * velocity_z_west + ) * hxInverse * hzInverse / 4 + + ( velocity_x_east * velocity_z_center - velocity_x_center * velocity_z_west + - velocity_x_center * velocity_z_center + velocity_x_west * velocity_z_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_12_y + + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south + - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south + + velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// wT_32_y + + ( ( velocity_z_upNorth * velocity_z_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_z_south + velocity_z_downSouth * velocity_z_south + ) * hyInverse * hzInverse / 4 + + ( velocity_y_north * velocity_z_center - velocity_y_center * velocity_z_south + - velocity_y_center * velocity_z_center + velocity_y_south * velocity_z_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// uT_13_z + + ( ( velocity_z_up * velocity_x_center - velocity_z_center * velocity_x_center + - velocity_z_center * velocity_x_down + velocity_z_down * velocity_x_down + ) * hzSquareInverse + + ( velocity_x_upEast * velocity_x_up - velocity_x_downEast * velocity_x_down + - velocity_x_upWest * velocity_x_up + velocity_x_downWest * velocity_x_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_23_z + + ( ( velocity_y_upNorth * velocity_y_up - velocity_y_downNorth * velocity_y_down + - velocity_y_upSouth * velocity_y_up + velocity_y_downSouth * velocity_y_down + ) * hyInverse * hzInverse / 4 + + ( velocity_z_up * velocity_y_center - velocity_z_center * velocity_y_down + - velocity_z_center * velocity_y_center + velocity_z_down * velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down + - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down + - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down + - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h new file mode 100644 index 000000000..5f02acfe2 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -0,0 +1,73 @@ +/*************************************************************************** + LaxFridrichsMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + LaxFridrichsMomentumBase() + : artificialViscosity( 1.0 ){}; + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h new file mode 100644 index 000000000..3e295c029 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h @@ -0,0 +1,383 @@ +/*************************************************************************** + LaxFridrichsMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) + - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse +// 1D T_11_x + - 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ) +// 2D T_11_x + + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hxInverse * hyInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_u[ up ] * velocity_z_up ) + - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ) +// 3D T_11_x + + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_21_x + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// T_31_x + + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h new file mode 100644 index 000000000..0df12c522 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h @@ -0,0 +1,363 @@ +/*************************************************************************** + LaxFridrichsMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ) +// 2D T_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_12_x + + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east + ) * hxSquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse + + ( ( rho_v[ up ] * velocity_z_up ) + - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ) +// T_12_y + + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D T_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_y + + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h new file mode 100644 index 000000000..e4f8501ec --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h @@ -0,0 +1,314 @@ +/*************************************************************************** + LaxFridrichsMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) + -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) + - ( rho_w[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_w[ north ] * velocity_y_north ) + - ( rho_w[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) + - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ) +// T_13_z + + ( ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// T_23_z + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + ) + * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h new file mode 100644 index 000000000..510dfecaf --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h @@ -0,0 +1,158 @@ +/*************************************************************************** + StegerWarming.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "StegerWarmingContinuity.h" +#include "StegerWarmingEnergy.h" +#include "StegerWarmingMomentumX.h" +#include "StegerWarmingMomentumY.h" +#include "StegerWarmingMomentumZ.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarming +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef StegerWarmingContinuity< Mesh, Real, Index > ContinuityOperatorType; + typedef StegerWarmingMomentumX< Mesh, Real, Index > MomentumXOperatorType; + typedef StegerWarmingMomentumY< Mesh, Real, Index > MomentumYOperatorType; + typedef StegerWarmingMomentumZ< Mesh, Real, Index > MomentumZOperatorType; + typedef StegerWarmingEnergy< Mesh, Real, Index > EnergyOperatorType; + + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VectorFieldType > VectorFieldPointer; + typedef SharedPointer< MeshType > MeshPointer; + + typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + StegerWarming() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h new file mode 100644 index 000000000..4cbee5c09 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h @@ -0,0 +1,386 @@ +/*************************************************************************** + StegerWarmingContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + static String getType() + { + return String( "StegerWarmingContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + RealType multiply (const RealType& a, const RealType& b ) const + { + return a * b; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h new file mode 100644 index 000000000..9f289fb2b --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h @@ -0,0 +1,717 @@ +/*************************************************************************** + StegerWarmingEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + StegerWarmingEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "StegerWarmingEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ) +// 1D uT_11_x + - 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse / 4 + * this->dynamicalViscosity; + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ) +// 2D uT_11_x + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// vT_21_x + + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east + - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west + - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_12_y + + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south + - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south + - velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 2D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) + ) +// 3D uT_11_x + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east + - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// vT_21_x + + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east + - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west + - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// wT_31_x + + ( ( velocity_z_upEast * velocity_z_east - velocity_z_downEast * velocity_z_east + - velocity_z_upWest * velocity_z_west + velocity_z_downWest * velocity_z_west + ) * hxInverse * hzInverse / 4 + + ( velocity_x_east * velocity_z_center - velocity_x_center * velocity_z_west + - velocity_x_center * velocity_z_center + velocity_x_west * velocity_z_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_12_y + + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south + - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south + + velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// wT_32_y + + ( ( velocity_z_upNorth * velocity_z_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_z_south + velocity_z_downSouth * velocity_z_south + ) * hyInverse * hzInverse / 4 + + ( velocity_y_north * velocity_z_center - velocity_y_center * velocity_z_south + - velocity_y_center * velocity_z_center + velocity_y_south * velocity_z_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// uT_13_z + + ( ( velocity_z_up * velocity_x_center - velocity_z_center * velocity_x_center + - velocity_z_center * velocity_x_down + velocity_z_down * velocity_x_down + ) * hzSquareInverse + + ( velocity_x_upEast * velocity_x_up - velocity_x_downEast * velocity_x_down + - velocity_x_upWest * velocity_x_up + velocity_x_downWest * velocity_x_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_23_z + + ( ( velocity_y_upNorth * velocity_y_up - velocity_y_downNorth * velocity_y_down + - velocity_y_upSouth * velocity_y_up + velocity_y_downSouth * velocity_y_down + ) * hyInverse * hzInverse / 4 + + ( velocity_z_up * velocity_y_center - velocity_z_center * velocity_y_down + - velocity_z_center * velocity_y_center + velocity_z_down * velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down + - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down + - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down + - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h new file mode 100644 index 000000000..3b0f0b89b --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h @@ -0,0 +1,137 @@ +/*************************************************************************** + StegerWarmingMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber + 1.0 ) * ( machNumber + 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber + 1.0 ) * (machNumber + 1.0 ) ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber - 1.0 ) * (machNumber - 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber - 1.0 ) * ( machNumber - 1.0 ) ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + RealType dynamicalViscosity; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h new file mode 100644 index 000000000..a8440605c --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h @@ -0,0 +1,433 @@ +/*************************************************************************** + StegerWarmingMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ) +// 1D T_11_x + - 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) +// 2D T_11_x + + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hxInverse * hyInverse + ) * this->dynamicalViscosity; + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ) +// 3D T_11_x + + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_21_x + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// T_31_x + + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h new file mode 100644 index 000000000..943663782 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h @@ -0,0 +1,403 @@ +/*************************************************************************** + StegerWarmingMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) +// 2D T_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_12_x + + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east + ) * hxSquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ) +// T_12_y + + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D T_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_y + + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h new file mode 100644 index 000000000..b74e36c2b --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h @@ -0,0 +1,338 @@ +/*************************************************************************** + StegerWarmingMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ) +// T_13_z + + ( ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// T_23_z + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + ) + * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity; + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h new file mode 100644 index 000000000..3d47a09be --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h @@ -0,0 +1,158 @@ +/*************************************************************************** + VanLeer.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "VanLeerContinuity.h" +#include "VanLeerEnergy.h" +#include "VanLeerMomentumX.h" +#include "VanLeerMomentumY.h" +#include "VanLeerMomentumZ.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeer +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef VanLeerContinuity< Mesh, Real, Index > ContinuityOperatorType; + typedef VanLeerMomentumX< Mesh, Real, Index > MomentumXOperatorType; + typedef VanLeerMomentumY< Mesh, Real, Index > MomentumYOperatorType; + typedef VanLeerMomentumZ< Mesh, Real, Index > MomentumZOperatorType; + typedef VanLeerEnergy< Mesh, Real, Index > EnergyOperatorType; + + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VectorFieldType > VectorFieldPointer; + typedef SharedPointer< MeshType > MeshPointer; + + typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + VanLeer() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h new file mode 100644 index 000000000..2c8217465 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h @@ -0,0 +1,382 @@ +/*************************************************************************** + VanLeerContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + static String getType() + { + return String( "VanLeerContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + RealType multiply (const RealType& a, const RealType& b ) const + { + return a * b; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h new file mode 100644 index 000000000..ed1166c3f --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h @@ -0,0 +1,681 @@ +/*************************************************************************** + VanLeerEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + VanLeerEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "VanLeerEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ) +// 1D uT_11_x + - 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse / 4 + * this->dynamicalViscosity; + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ) +// 2D uT_11_x + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// vT_21_x + + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east + - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west + - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_12_y + + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south + - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south + - velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 2D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) + ) +// 3D uT_11_x + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east + - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// vT_21_x + + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east + - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west + - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// wT_31_x + + ( ( velocity_z_upEast * velocity_z_east - velocity_z_downEast * velocity_z_east + - velocity_z_upWest * velocity_z_west + velocity_z_downWest * velocity_z_west + ) * hxInverse * hzInverse / 4 + + ( velocity_x_east * velocity_z_center - velocity_x_center * velocity_z_west + - velocity_x_center * velocity_z_center + velocity_x_west * velocity_z_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_12_y + + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south + - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south + + velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// wT_32_y + + ( ( velocity_z_upNorth * velocity_z_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_z_south + velocity_z_downSouth * velocity_z_south + ) * hyInverse * hzInverse / 4 + + ( velocity_y_north * velocity_z_center - velocity_y_center * velocity_z_south + - velocity_y_center * velocity_z_center + velocity_y_south * velocity_z_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// uT_13_z + + ( ( velocity_z_up * velocity_x_center - velocity_z_center * velocity_x_center + - velocity_z_center * velocity_x_down + velocity_z_down * velocity_x_down + ) * hzSquareInverse + + ( velocity_x_upEast * velocity_x_up - velocity_x_downEast * velocity_x_down + - velocity_x_upWest * velocity_x_up + velocity_x_downWest * velocity_x_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_23_z + + ( ( velocity_y_upNorth * velocity_y_up - velocity_y_downNorth * velocity_y_down + - velocity_y_upSouth * velocity_y_up + velocity_y_downSouth * velocity_y_down + ) * hyInverse * hzInverse / 4 + + ( velocity_z_up * velocity_y_center - velocity_z_center * velocity_y_down + - velocity_z_center * velocity_y_center + velocity_z_down * velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down + - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down + - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down + - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h new file mode 100644 index 000000000..50b0349a5 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h @@ -0,0 +1,129 @@ +/*************************************************************************** + VanLeerMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * ( - 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + MeshFunctionPointer pressure; + + RealType dynamicalViscosity; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h new file mode 100644 index 000000000..d6122d37e --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h @@ -0,0 +1,433 @@ +/*************************************************************************** + VanLeerMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ) +// 1D T_11_x + - 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) +// 2D T_11_x + + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hxInverse * hyInverse + ) * this->dynamicalViscosity; + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ) +// 3D T_11_x + + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_21_x + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// T_31_x + + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h new file mode 100644 index 000000000..2a5e4a23a --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h @@ -0,0 +1,403 @@ +/*************************************************************************** + VanLeerMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) +// 2D T_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_12_x + + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east + ) * hxSquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ) +// T_12_y + + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D T_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_y + + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h new file mode 100644 index 000000000..5b2ec810b --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h @@ -0,0 +1,338 @@ +/*************************************************************************** + VanLeerMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ) +// T_13_z + + ( ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// T_23_z + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + ) + * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity; + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/PhysicalVariablesGetter.h b/src/Examples/flows/PhysicalVariablesGetter.h new file mode 100644 index 000000000..f1ba6bd12 --- /dev/null +++ b/src/Examples/flows/PhysicalVariablesGetter.h @@ -0,0 +1,122 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { + +template< typename Mesh > +class PhysicalVariablesGetter +{ + public: + + typedef Mesh MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + + class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + VelocityGetter( MeshFunctionPointer density, + MeshFunctionPointer momentum ) + : density( density ), momentum( momentum ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return momentum.template getData< DeviceType >()( meshEntity ) / + density.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, momentum; + }; + + class PressureGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + PressureGetter( MeshFunctionPointer density, + MeshFunctionPointer energy, + VelocityFieldPointer momentum, + const RealType& gamma ) + : density( density ), energy( energy ), momentum( momentum ), gamma( gamma ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + const RealType e = energy.template getData< DeviceType >()( meshEntity ); + const RealType rho = density.template getData< DeviceType >()( meshEntity ); + const RealType momentumNorm = momentum.template getData< DeviceType >().getVector( meshEntity ).lpNorm( 2.0 ); + if( rho == 0.0 ) + return 0; + else + return ( gamma - 1.0 ) * ( e - 0.5 * momentumNorm * momentumNorm / rho ); + } + + protected: + const MeshFunctionPointer density, energy; + const VelocityFieldPointer momentum; + const RealType gamma; + }; + + + void getVelocity( const ConservativeVariablesPointer& conservativeVariables, + VelocityFieldPointer& velocity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), + ( *conservativeVariables->getMomentum() )[ i ] ); + evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); + } + } + + void getPressure( const ConservativeVariablesPointer& conservativeVariables, + const RealType& gamma, + MeshFunctionPointer& pressure ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; + SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), + conservativeVariables->getEnergy(), + conservativeVariables->getMomentum(), + gamma ); + evaluator.evaluate( pressure, pressureGetter ); + } + +}; + +} //namespace TNL diff --git a/src/Examples/flows/RiemannProblemInitialCondition.h b/src/Examples/flows/RiemannProblemInitialCondition.h new file mode 100644 index 000000000..b1819b1eb --- /dev/null +++ b/src/Examples/flows/RiemannProblemInitialCondition.h @@ -0,0 +1,1417 @@ +/*************************************************************************** + RiemannProblemInitialCondition.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { +template +class RiemannProblemInitialConditionSetter +{ + +}; + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 1,MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 2,MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWDMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEDMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NWDMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NEDMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + +template< typename Mesh > +class RiemannProblemInitialCondition +{ + public: + + typedef Mesh MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; + + RiemannProblemInitialCondition() + : discontinuityPlacement( 0.5 ), + leftDensity( 1.0 ), rightDensity( 1.0 ), + leftVelocity( -2.0 ), rightVelocity( 2.0 ), + leftPressure( 0.4 ), rightPressure( 0.4 ), + gamma( 1.67 ){} + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "discontinuity-placement-0", "x-coordinate of the discontinuity placement.", 0.5 ); + config.addEntry< double >( prefix + "discontinuity-placement-1", "y-coordinate of the discontinuity placement.", 0.5 ); + config.addEntry< double >( prefix + "discontinuity-placement-2", "z-coordinate of the discontinuity placement.", 0.5 ); +/* + config.addEntry< double >( prefix + "left-density", "Density on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-density", "Density on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "left-velocity-0", "x-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "left-velocity-1", "y-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "left-velocity-2", "z-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-velocity-0", "x-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "right-velocity-1", "y-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "right-velocity-2", "z-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "left-pressure", "Pressure on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-pressure", "Pressure on the right side of the discontinuity.", 0.0 ); +*/ + config.addEntry< double >( prefix + "NWU-density", "This sets a value of northwest up density.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-0", "This sets a value of northwest up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-1", "This sets a value of northwest up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-2", "This sets a value of northwest up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-pressure", "This sets a value of northwest up pressure.", 1.0 ); + config.addEntry< double >( prefix + "SWU-density", "This sets a value of southwest up density.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-0", "This sets a value of southwest up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-1", "This sets a value of southwest up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-2", "This sets a value of southwest up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-pressure", "This sets a value of southwest up pressure.", 1.0 ); + config.addEntry< double >( prefix + "NWD-density", "This sets a value of northwest down density.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-0", "This sets a value of northwest down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-1", "This sets a value of northwest down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-2", "This sets a value of northwest down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-pressure", "This sets a value of northwest down pressure.", 1.0 ); + config.addEntry< double >( prefix + "SWD-density", "This sets a value of southwest down density.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-0", "This sets a value of southwest down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-1", "This sets a value of southwest down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-2", "This sets a value of southwest down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-pressure", "This sets a value of southwest down pressure.", 1.0 ); + config.addEntry< double >( prefix + "NEU-density", "This sets a value of northeast up density.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-0", "This sets a value of northeast up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-1", "This sets a value of northeast up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-2", "This sets a value of northeast up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-pressure", "This sets a value of northeast up pressure.", 1.0 ); + config.addEntry< double >( prefix + "SEU-density", "This sets a value of southeast up density.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-0", "This sets a value of southeast up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-1", "This sets a value of southeast up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-2", "This sets a value of southeast up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-pressure", "This sets a value of southeast up pressure.", 1.0 ); + config.addEntry< double >( prefix + "NED-density", "This sets a value of northeast down density.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-0", "This sets a value of northeast down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-1", "This sets a value of northeast down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-2", "This sets a value of northeast down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-pressure", "This sets a value of northeast down pressure.", 1.0 ); + config.addEntry< double >( prefix + "SED-density", "This sets a value of southeast down density.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-0", "This sets a value of southeast down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-1", "This sets a value of southeast down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-2", "This sets a value of southeast down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-pressure", "This sets a value of southeast down pressure.", 1.0 ); + config.addEntry< double >( prefix + "gamma", "Gamma in the ideal gas state equation.", 1.4 ); + + config.addEntry< String >( prefix + "initial", " One of predefined initial condition.", "none"); + config.addEntryEnum< String >( "none" ); + config.addEntryEnum< String >( "1D_2" ); + config.addEntryEnum< String >( "1D_3a" ); + config.addEntryEnum< String >( "1D_4" ); + config.addEntryEnum< String >( "1D_5" ); + config.addEntryEnum< String >( "1D_6" ); + config.addEntryEnum< String >( "1D_Noh" ); + config.addEntryEnum< String >( "1D_peak" ); + config.addEntryEnum< String >( "2D_3" ); + config.addEntryEnum< String >( "2D_4" ); + config.addEntryEnum< String >( "2D_6" ); + config.addEntryEnum< String >( "2D_12" ); + config.addEntryEnum< String >( "2D_15" ); + config.addEntryEnum< String >( "2D_17" ); + } + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + String initial = parameters.getParameter< String >( prefix + "initial" ); + if(initial == prefix + "none") + { + this->discontinuityPlacement.setup( parameters, prefix + "discontinuity-placement-" ); + this->gamma = parameters.getParameter< double >( prefix + "gamma" ); +/* + this->leftVelocity.setup( parameters, prefix + "left-velocity-" ); + this->rightVelocity.setup( parameters, prefix + "right-velocity-" ); + this->leftDensity = parameters.getParameter< double >( prefix + "left-density" ); + this->rightDensity = parameters.getParameter< double >( prefix + "right-density" ); + this->leftPressure = parameters.getParameter< double >( prefix + "left-pressure" ); + this->rightPressure = parameters.getParameter< double >( prefix + "right-pressure" ); +*/ + + this->NWUDensity = parameters.getParameter< RealType >( prefix + "NWU-density" ); + this->NWUVelocity.setup( parameters, prefix + "NWU-velocity-" ); + this->NWUPressure = parameters.getParameter< RealType >( prefix + "NWU-pressure" ); + this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); + this->NWUMomentum = NWUVelocity * NWUDensity; + + this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); + this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); + this->SWUPressure = parameters.getParameter< RealType >( prefix + "SWU-pressure" ); + this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); + this->SWUMomentum = SWUVelocity * SWUDensity; + + this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); + this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); + this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); + this->SWUEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); + this->NWDMomentum = NWDVelocity * NWDDensity; + + this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); + this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); + this->SWDPressure = parameters.getParameter< RealType >( prefix + "SWD-pressure" ); + this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); + this->SWDMomentum = SWDVelocity * SWDDensity; + + this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); + this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); + this->NEUPressure = parameters.getParameter< RealType >( prefix + "NEU-pressure" ); + this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); + this->NEUMomentum = NEUVelocity * NEUDensity; + + this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); + this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); + this->SEUPressure = parameters.getParameter< RealType >( prefix + "SEU-pressure" ); + this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); + this->SEUMomentum = SEUVelocity * SEUDensity; + + this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); + this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); + this->NEDPressure = parameters.getParameter< RealType >( prefix + "NED-pressure" ); + this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); + this->NEDMomentum = NEDVelocity * NEDDensity; + + this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); + this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); + this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); + this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); + this->SEDMomentum = SEDVelocity * SEDDensity; + + } + if(initial == prefix + "1D_2") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -2.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 2.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_3a") + predefinedInitialCondition( 1.4, 0.8, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 1000.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.01, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -19.59745, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -19.59745, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_4") + predefinedInitialCondition( 1.666, 0.4, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 5.99924, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 5.99242, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 460.894, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 46.095, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 19.5975, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -6.19633, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_5") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_6") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.1, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_Noh") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.000001, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.000001, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_peak") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 0.12612, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 6.5915, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 782.929, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 3.15449, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 8.90470, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 2.26542, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_3") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5323, 0.138, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.5, 0.5323, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.3, 0.029, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.5, 0.3, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 1.206, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.206, 1.206, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 1.206, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_4") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5065, 1.1, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.1, 0.5065, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.35, 1.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.1, 0.35, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.8939, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.8939, 0.8939, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.8939, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + + if(initial == prefix + "2D_6") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 2.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 3.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.75, 0.5, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -0.75, 0.5, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.75, -0.5, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -0.75, -0.5, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_12") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 1.0, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.5313, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.4, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.7276, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.7276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + + if(initial == prefix + "2D_15") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5197, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 0.5313, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.4, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + -0.6259, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.1, -0.3, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.1, -0.3, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.1, 0.4276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_17") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 2.0, 1.0625, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 0.5197, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.2145, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, -0.4, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 1.1259, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + return true; + } + + void setDiscontinuityPlacement( const PointType& v ) + { + this->discontinuityPlacement = v; + } + + const PointType& getDiscontinuityPlasement() const + { + return this->discontinuityPlacement; + } + + void setLeftDensity( const RealType& leftDensity ) + { + this->leftDensity = leftDensity; + } + + const RealType& getLeftDensity() const + { + return this->leftDensity; + } + + void setRightDensity( const RealType& rightDensity ) + { + this->rightDensity = rightDensity; + } + + const RealType& getRightDensity() const + { + return this->rightDensity; + } + + void setLeftVelocity( const PointType& leftVelocity ) + { + this->leftVelocity = leftVelocity; + } + + const PointType& getLeftVelocity() const + { + return this->leftVelocity; + } + + void setRightVelocity( const RealType& rightVelocity ) + { + this->rightVelocity = rightVelocity; + } + + const PointType& getRightVelocity() const + { + return this->rightVelocity; + } + + void setLeftPressure( const RealType& leftPressure ) + { + this->leftPressure = leftPressure; + } + + const RealType& getLeftPressure() const + { + return this->leftPressure; + } + + void setRightPressure( const RealType& rightPressure ) + { + this->rightPressure = rightPressure; + } + + const RealType& getRightPressure() const + { + return this->rightPressure; + } + + + void predefinedInitialCondition( double preGamma, double preDiscX, double preDiscY, double preDiscZ, + double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ) + + { + this->discontinuityPlacement = PointLoad(preDiscX, preDiscY, preDiscZ); + this->gamma = preGamma; + + this->NWUDensity = preNWUDensity; + this->NWUVelocity = PointLoad(preNWUVelocityX, preNWUVelocityY, preNWUVelocityZ); + this->NWUPressure = preNWUPressure; + this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); + this->NWUMomentum = NWUVelocity * NWUDensity; + + this->SWUDensity = preNWUDensity; + this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); + this->SWUPressure = preSWUPressure; + this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); + this->SWUMomentum = SWUVelocity * SWUDensity; + + this->NWDDensity = preNWDDensity; + this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); + this->NWDPressure = preNWDPressure; + this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); + this->NWDMomentum = NWDVelocity * NWDDensity; + + this->SWDDensity = preSWDDensity; + this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); + this->SWDPressure = preSWDPressure; + this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); + this->SWDMomentum = SWDVelocity * SWDDensity; + + this->NEUDensity = preNEUDensity; + this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); + this->NEUPressure = preNEUPressure; + this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); + this->NEUMomentum = NEUVelocity * NEUDensity; + + this->SEUDensity = preSEUDensity; + this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); + this->SEUPressure = preSEUPressure; + this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); + this->SEUMomentum = SEUVelocity * SEUDensity; + + this->NEDDensity = preNEDDensity; + this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); + this->NEDPressure = preNEDPressure; + this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); + this->NEDMomentum = NEDVelocity * NEDDensity; + + this->SEDDensity = preSEDDensity; + this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); + this->SEDPressure = preSEDPressure; + this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); + this->SEDMomentum = SEDVelocity * SEDDensity; + + std::cout << this->SEDEnergy; + std::cout << this->SWDEnergy; + + } + + PointType PointLoad( RealType ValueX, RealType ValueY, RealType ValueZ) + { + PointType point; + switch (Dimensions) + { + case 1: point[ 0 ] = ValueX; + break; + case 2: point[ 0 ] = ValueX; + point[ 1 ] = ValueY; + break; + case 3: point[ 0 ] = ValueX; + point[ 1 ] = ValueY; + point[ 2 ] = ValueZ; + break; + } + return point; + } + + RealType Energy( RealType Density, RealType Pressure, RealType gamma, PointType Velocity) + { + RealType energy; + switch (Dimensions) + { + case 1: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ))); + break; + case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); + break; + case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 3 ], 2 ))); + break; // druhou mocninu ps8t jako sou4in + } + return energy; + } + + void setInitialCondition( CompressibleConservativeVariables< MeshType >& conservativeVariables, + const PointType& center = PointType( 0.0 ) ) + { + RiemannProblemInitialConditionSetter* variablesSetter = new RiemannProblemInitialConditionSetter; + variablesSetter->setGamma(this->gamma); + variablesSetter->setDensity(this->NWUDensity, + this->NEUDensity, + this->SWUDensity, + this->SEUDensity, + this->NWDDensity, + this->NEDDensity, + this->SWDDensity, + this->SEDDensity); + variablesSetter->setMomentum(this->NWUMomentum, + this->NEUMomentum, + this->SWUMomentum, + this->SEUMomentum, + this->NWDMomentum, + this->NEDMomentum, + this->SWDMomentum, + this->SEDMomentum); + variablesSetter->setEnergy(this->NWUEnergy, + this->NEUEnergy, + this->SWUEnergy, + this->SEUEnergy, + this->NWDEnergy, + this->NEDEnergy, + this->SWDEnergy, + this->SEDEnergy); + variablesSetter->setDiscontinuity(this->discontinuityPlacement); + variablesSetter->placeDensity(conservativeVariables); + variablesSetter->placeMomentum(conservativeVariables); + variablesSetter->placeEnergy(conservativeVariables); + +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + +/* + typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; + typedef Operators::Analytic::Sign< Dimensions, RealType > SignType; + typedef Functions::OperatorFunction< SignType, VectorNormType > InitialConditionType; + typedef SharedPointer< InitialConditionType, DeviceType > InitialConditionPointer; + + InitialConditionPointer initialCondition; + initialCondition->getFunction().setCenter( center ); + initialCondition->getFunction().setMaxNorm( true ); + initialCondition->getFunction().setRadius( discontinuityPlacement[ 0 ] ); + discontinuityPlacement *= 1.0 / discontinuityPlacement[ 0 ]; + for( int i = 1; i < Dimensions; i++ ) + discontinuityPlacement[ i ] = 1.0 / discontinuityPlacement[ i ]; + initialCondition->getFunction().setAnisotropy( discontinuityPlacement ); + initialCondition->getFunction().setMultiplicator( -1.0 ); + + Functions::MeshFunctionEvaluator< MeshFunctionType, InitialConditionType > evaluator; +*/ + /**** + * Density + */ +/* + conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); +*/ +/* + initialCondition->getOperator().setPositiveValue( leftDensity ); + initialCondition->getOperator().setNegativeValue( rightDensity ); + evaluator.evaluate( conservativeVariables.getDensity(), initialCondition ); + conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); +*/ + /**** + * Momentum + */ + +/* + for( int i = 0; i < Dimensions; i++ ) + { + initialCondition->getOperator().setPositiveValue( leftDensity * leftVelocity[ i ] ); + initialCondition->getOperator().setNegativeValue( rightDensity * rightVelocity[ i ] ); + evaluator.evaluate( conservativeVariables.getMomentum()[ i ], initialCondition ); + } +*/ + /**** + * Energy + */ +/* + conservativeVariables.getEnergy()->write( "energy-init", "gnuplot" ); +*/ +/* + const RealType leftKineticEnergy = leftVelocity.lpNorm( 2.0 ); + const RealType rightKineticEnergy = rightVelocity.lpNorm( 2.0 ); + const RealType leftEnergy = leftPressure / ( gamma - 1.0 ) + 0.5 * leftDensity * leftKineticEnergy * leftKineticEnergy; + const RealType rightEnergy = rightPressure / ( gamma - 1.0 ) + 0.5 * rightDensity * rightKineticEnergy * rightKineticEnergy; + initialCondition->getOperator().setPositiveValue( leftEnergy ); + initialCondition->getOperator().setNegativeValue( rightEnergy ); + evaluator.evaluate( (* conservativeVariables.getEnergy()), initialCondition ); + (* conservativeVariables.getEnergy())->write( "energy-init", "gnuplot" ); +*/ + } + + + protected: + + PointType discontinuityPlacement; + PointType NWUVelocity, NEUVelocity, SWUVelocity, SEUVelocity, NWDVelocity, NEDVelocity, SWDVelocity, SEDVelocity; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUPressure, NEUPressure, SWUPressure, SEUPressure, NWDPressure, NEDPressure, SWDPressure, SEDPressure; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType leftDensity, rightDensity; + PointType leftVelocity, rightVelocity; + RealType leftPressure, rightPressure; + + RealType gamma; // gamma in the ideal gas state equation +}; + +} //namespace TNL diff --git a/src/Examples/flows/euler.cpp b/src/Examples/flows/euler.cpp new file mode 100644 index 000000000..4d76005cb --- /dev/null +++ b/src/Examples/flows/euler.cpp @@ -0,0 +1 @@ +#include "euler.h" diff --git a/src/Examples/flows/euler.cu b/src/Examples/flows/euler.cu new file mode 100644 index 000000000..4d76005cb --- /dev/null +++ b/src/Examples/flows/euler.cu @@ -0,0 +1 @@ +#include "euler.h" diff --git a/src/Examples/flows/euler.h b/src/Examples/flows/euler.h new file mode 100644 index 000000000..6abae004a --- /dev/null +++ b/src/Examples/flows/euler.h @@ -0,0 +1,134 @@ +#include +#include +#include +#include +#include +#include +#include "eulerProblem.h" +#include "DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h" +#include "DifferentialOperators/Euler/Steger-Warming/StegerWarming.h" +#include "DifferentialOperators/Euler/VanLeer/VanLeer.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class eulerConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "dirichlet"); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< String >( "differential-operator", "Choose the differential operator.", "Lax-Friedrichs"); + config.addEntryEnum< String >( "Lax-Friedrichs" ); + config.addEntryEnum< String >( "Steger-Warming" ); + config.addEntryEnum< String >( "VanLeer" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + typedef Meshes::Grid< 3 > Mesh; + LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class eulerSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + typedef LaxFridrichs< MeshType, Real, Index > ApproximateOperator; + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); + if( differentialOperatorType == "Lax-Friedrichs" ) + typedef LaxFridrichs< MeshType, Real, Index > ApproximateOperator; + else if( differentialOperatorType == "Steger-Warming" ) + typedef StegerWarming< MeshType, Real, Index > ApproximateOperator; + else if( differentialOperatorType == "VanLeer" ) + typedef VanLeer< MeshType, Real, Index > ApproximateOperator; + + /**** + * Resolve the template arguments of your solver here. + * The following code is for the Dirichlet and the Neumann boundary conditions. + * Both can be constant or defined as descrete values of Vector. + */ + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( parameters.checkParameter( "boundary-conditions-constant" ) ) + { + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + if( boundaryConditionsType == "dirichlet" ) + { + typedef Operators::DirichletBoundaryConditions< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef Operators::NeumannBoundaryConditions< MeshType, Constant, Real, Index > BoundaryConditions; + typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef Operators::DirichletBoundaryConditions< MeshType, MeshFunction, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef Operators::NeumannBoundaryConditions< MeshType, MeshFunction, Real, Index > BoundaryConditions; + typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< eulerSetter, eulerConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +} diff --git a/src/Examples/flows/eulerProblem.h b/src/Examples/flows/eulerProblem.h new file mode 100644 index 000000000..cb24108ef --- /dev/null +++ b/src/Examples/flows/eulerProblem.h @@ -0,0 +1,118 @@ +/*************************************************************************** + eulerProblem.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include "CompressibleConservativeVariables.h" + + +using namespace TNL::Problems; + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +class eulerProblem: + public PDEProblem< Mesh, + Communicator, + typename InviscidOperators::RealType, + typename Mesh::DeviceType, + typename InviscidOperators::IndexType > +{ + public: + + typedef typename InviscidOperators::RealType RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef typename InviscidOperators::IndexType IndexType; + typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; + + typedef Communicator CommunicatorType; + + using typename BaseType::MeshType; + using typename BaseType::MeshPointer; + using typename BaseType::DofVectorType; + using typename BaseType::DofVectorPointer; + static const int Dimensions = Mesh::getMeshDimension(); + + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef SharedPointer< InviscidOperators > InviscidOperatorsPointer; + typedef SharedPointer< BoundaryCondition > BoundaryConditionPointer; + typedef SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; + + static String getType(); + + String getPrologHeader() const; + + void writeProlog( Logger& logger, + const Config::ParameterContainer& parameters ) const; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ); + + bool setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ); + + template< typename Matrix > + bool setupLinearSystem( Matrix& matrix ); + + bool makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ); + + IndexType getDofs() const; + + void bindDofs( DofVectorPointer& dofs ); + + void getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ); + + template< typename Matrix > + void assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs, + Matrix& matrix, + DofVectorPointer& rightHandSide ); + + bool postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ); + + protected: + + InviscidOperatorsPointer inviscidOperatorsPointer; + + BoundaryConditionPointer boundaryConditionPointer; + RightHandSidePointer rightHandSidePointer; + + ConservativeVariablesPointer conservativeVariables, + conservativeVariablesRHS; + + VelocityFieldPointer velocity; + MeshFunctionPointer pressure; + + RealType gamma; +}; + +} // namespace TNL + +#include "eulerProblem_impl.h" + diff --git a/src/Examples/flows/eulerProblem_impl.h b/src/Examples/flows/eulerProblem_impl.h new file mode 100644 index 000000000..d54261143 --- /dev/null +++ b/src/Examples/flows/eulerProblem_impl.h @@ -0,0 +1,416 @@ +/*************************************************************************** + eulerProblem_impl.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "RiemannProblemInitialCondition.h" +#include "CompressibleConservativeVariables.h" +#include "PhysicalVariablesGetter.h" +#include "eulerProblem.h" + +//#include "LaxFridrichsContinuity.h" +//#include "LaxFridrichsEnergy.h" +//#include "LaxFridrichsMomentumX.h" +//#include "LaxFridrichsMomentumY.h" +//#include "LaxFridrichsMomentumZ.h" + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getType() +{ + return String( "eulerProblem< " ) + Mesh :: getType() + " >"; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getPrologHeader() const +{ + return String( "flow solver" ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const +{ + /**** + * Add data you want to have in the computation report (log) as follows: + * logger.writeParameter< double >( "Parameter description", parameter ); + */ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setup( const Config::ParameterContainer& parameters, + const String& prefix ) +{ + if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || + ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || + ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) + return false; + this->gamma = parameters.getParameter< double >( "gamma" ); + velocity->setMesh( this->getMesh() ); + pressure->setMesh( this->getMesh() ); + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +typename eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >::IndexType +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getDofs() const +{ + /**** + * Return number of DOFs (degrees of freedom) i.e. number + * of unknowns to be resolved by the main solver. + */ + return this->conservativeVariables->getDofs( this->getMesh() ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +bindDofs( DofVectorPointer& dofVector ) +{ + this->conservativeVariables->bind( this->getMesh(), dofVector ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ) +{ + CompressibleConservativeVariables< MeshType > conservativeVariables; + conservativeVariables.bind( this->getMesh(), dofs ); + const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); + if( initialConditionType == "riemann-problem" ) + { + RiemannProblemInitialCondition< MeshType > initialCondition; + if( ! initialCondition.setup( parameters ) ) + return false; + initialCondition.setInitialCondition( conservativeVariables ); + return true; + } + std::cerr << "Unknown initial condition " << initialConditionType << std::endl; + return false; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +bool +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setupLinearSystem( Matrix& matrix ) +{ +/* const IndexType dofs = this->getDofs(); + typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; + CompressedRowLengthsVectorType rowLengths; + if( ! rowLengths.setSize( dofs ) ) + return false; + MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; + matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, + differentialOperator, + boundaryCondition, + rowLengths ); + matrix.setDimensions( dofs, dofs ); + if( ! matrix.setCompressedRowLengths( rowLengths ) ) + return false;*/ + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ) +{ + std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; + + this->bindDofs( dofs ); + PhysicalVariablesGetter< MeshType > physicalVariablesGetter; + physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + + FileName fileName; + fileName.setExtension( "tnl" ); + fileName.setIndex( step ); + fileName.setFileNameBase( "density-" ); + if( ! this->conservativeVariables->getDensity()->save( fileName.getFileName() ) ) + return false; + + fileName.setFileNameBase( "velocity-" ); + if( ! this->velocity->save( fileName.getFileName() ) ) + return false; + + fileName.setFileNameBase( "pressure-" ); + if( ! this->pressure->save( fileName.getFileName() ) ) + return false; + + fileName.setFileNameBase( "energy-" ); + if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) + return false; + + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ) +{ + typedef typename MeshType::Cell Cell; + + /**** + * Bind DOFs + */ + this->conservativeVariables->bind( this->getMesh(), _u ); + this->conservativeVariablesRHS->bind( this->getMesh(), _fu ); + this->velocity->setMesh( this->getMesh() ); + this->pressure->setMesh( this->getMesh() ); + + /**** + * Resolve the physical variables + */ + PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; + physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + + /**** + * Set-up operators + */ + typedef typename InviscidOperators::ContinuityOperatorType ContinuityOperatorType; + typedef typename InviscidOperators::MomentumXOperatorType MomentumXOperatorType; + typedef typename InviscidOperators::MomentumYOperatorType MomentumYOperatorType; + typedef typename InviscidOperators::MomentumZOperatorType MomentumZOperatorType; + typedef typename InviscidOperators::EnergyOperatorType EnergyOperatorType; + + this->inviscidOperatorsPointer->setTau( tau ); + this->inviscidOperatorsPointer->setVelocity( this->velocity ); + this->inviscidOperatorsPointer->setPressure( this->pressure ); + this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); + this->inviscidOperatorsPointer->setGamma( this->gamma ); + + /**** + * Continuity equation + */ + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, ContinuityOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterContinuity; + explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); + explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer ); + explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); + explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getDensity(), + this->conservativeVariablesRHS->getDensity() ); + + /**** + * Momentum equations + */ + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumXOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumX; + explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); + explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer ); + explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); + explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); + + if( Dimensions > 1 ) + { + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumYOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumY; + explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); + explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer ); + explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); + explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); + } + + if( Dimensions > 2 ) + { + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumZ; + explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); + explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer ); + explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); + explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); + } + + + /**** + * Energy equation + */ + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, EnergyOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterEnergy; + explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); + explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer ); + explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); + explicitUpdaterEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getEnergy(), // uRhoVelocityX, + this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); + + /*this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); + this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); + this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); + getchar();*/ + +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +void +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + Matrix& matrix, + DofVectorPointer& b ) +{ +/* LinearSystemAssembler< Mesh, + MeshFunctionType, + InviscidOperators, + BoundaryCondition, + RightHandSide, + BackwardTimeDiscretisation, + Matrix, + DofVectorType > systemAssembler; + + MeshFunction< Mesh > u( mesh, _u ); + systemAssembler.template assembly< typename Mesh::Cell >( time, + tau, + this->differentialOperator, + this->boundaryCondition, + this->rightHandSide, + u, + matrix, + b );*/ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ) +{ + /* + typedef typename MeshType::Cell Cell; + int count = mesh->template getEntitiesCount< Cell >()/4; + //bind _u + this->_uRho.bind( *dofs, 0, count); + this->_uRhoVelocityX.bind( *dofs, count, count); + this->_uRhoVelocityY.bind( *dofs, 2 * count, count); + this->_uEnergy.bind( *dofs, 3 * count, count); + + MeshFunctionType velocity( mesh, this->velocity ); + MeshFunctionType velocityX( mesh, this->velocityX ); + MeshFunctionType velocityY( mesh, this->velocityY ); + MeshFunctionType pressure( mesh, this->pressure ); + MeshFunctionType uRho( mesh, _uRho ); + MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); + MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); + MeshFunctionType uEnergy( mesh, _uEnergy ); + //Generating differential operators + Velocity euler2DVelocity; + VelocityX euler2DVelocityX; + VelocityY euler2DVelocityY; + Pressure euler2DPressure; + + //velocityX + euler2DVelocityX.setRhoVelX(uRhoVelocityX); + euler2DVelocityX.setRho(uRho); +// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; +// velocityX = OFVelocityX; + + //velocityY + euler2DVelocityY.setRhoVelY(uRhoVelocityY); + euler2DVelocityY.setRho(uRho); +// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; +// velocityY = OFVelocityY; + + //velocity + euler2DVelocity.setVelX(velocityX); + euler2DVelocity.setVelY(velocityY); +// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; +// velocity = OFVelocity; + + //pressure + euler2DPressure.setGamma(gamma); + euler2DPressure.setVelocity(velocity); + euler2DPressure.setEnergy(uEnergy); + euler2DPressure.setRho(uRho); +// OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure; +// pressure = OFPressure; + */ + return true; +} + +} // namespace TNL + diff --git a/src/Examples/flows/flowsBuildConfigTag.h b/src/Examples/flows/flowsBuildConfigTag.h new file mode 100644 index 000000000..0039caada --- /dev/null +++ b/src/Examples/flows/flowsBuildConfigTag.h @@ -0,0 +1,72 @@ +#ifndef FLOWSBUILDCONFIGTAG_H_ +#define FLOWSBUILDCONFIGTAG_H_ + +#include +#include + +namespace TNL { + +class flowsBuildConfigTag{}; + +namespace Solvers { + +/**** + * Turn off support for float and long double. + */ +template<> struct ConfigTagReal< flowsBuildConfigTag, float > { enum { enabled = false }; }; +template<> struct ConfigTagReal< flowsBuildConfigTag, long double > { enum { enabled = false }; }; + +/**** + * Turn off support for short int and long int indexing. + */ +template<> struct ConfigTagIndex< flowsBuildConfigTag, short int >{ enum { enabled = false }; }; +template<> struct ConfigTagIndex< flowsBuildConfigTag, long int >{ enum { enabled = false }; }; + +//template< int Dimension > struct ConfigTagDimension< flowsBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; + +/**** + * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. + */ +/*template< int Dimension, typename Real, typename Device, typename Index > + struct ConfigTagMesh< flowsBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > + { enum { enabled = ConfigTagDimension< flowsBuildConfigTag, Dimension >::enabled && + ConfigTagReal< flowsBuildConfigTag, Real >::enabled && + ConfigTagDevice< flowsBuildConfigTag, Device >::enabled && + ConfigTagIndex< flowsBuildConfigTag, Index >::enabled }; }; +*/ +/**** + * Please, chose your preferred time discretisation here. + */ +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; + +/**** + * Only the Runge-Kutta-Merson solver is enabled by default. + */ +template<> struct ConfigTagExplicitSolver< flowsBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; + +} // namespace Solvers + +namespace Meshes { +namespace BuildConfigTags { + +template< int Dimensions > struct GridDimensionTag< flowsBuildConfigTag, Dimensions >{ enum { enabled = ( Dimensions == 1 ) }; }; + +/**** + * Turn off support for float and long double. + */ +template<> struct GridRealTag< flowsBuildConfigTag, float > { enum { enabled = false }; }; +template<> struct GridRealTag< flowsBuildConfigTag, long double > { enum { enabled = false }; }; + +/**** + * Turn off support for short int and long int indexing. + */ +template<> struct GridIndexTag< flowsBuildConfigTag, short int >{ enum { enabled = false }; }; +template<> struct GridIndexTag< flowsBuildConfigTag, long int >{ enum { enabled = false }; }; + +} // namespace BuildConfigTags +} // namespace Meshes +} // namespace TNL + +#endif /* FLOWSBUILDCONFIGTAG_H_ */ diff --git a/src/Examples/flows/flowsRhs.h b/src/Examples/flows/flowsRhs.h new file mode 100644 index 000000000..edea64869 --- /dev/null +++ b/src/Examples/flows/flowsRhs.h @@ -0,0 +1,35 @@ +#ifndef FLOWSRHS_H_ +#define FLOWSRHS_H_ + +#include + +namespace TNL { + +template< typename Mesh, typename Real >class flowsRhs + : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > + { + public: + + typedef Mesh MeshType; + typedef Real RealType; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + template< typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshEntity& entity, + const Real& time = 0.0 ) const + { + typedef typename MeshEntity::MeshType::PointType PointType; + PointType v = entity.getCenter(); + return 0.0; + } +}; + +} //namespace TNL + +#endif /* FLOWSRHS_H_ */ diff --git a/src/Examples/flows/navierStokes.cpp b/src/Examples/flows/navierStokes.cpp new file mode 100644 index 000000000..7dffcb059 --- /dev/null +++ b/src/Examples/flows/navierStokes.cpp @@ -0,0 +1 @@ +#include "navierStokes.h" diff --git a/src/Examples/flows/navierStokes.cu b/src/Examples/flows/navierStokes.cu new file mode 100644 index 000000000..7dffcb059 --- /dev/null +++ b/src/Examples/flows/navierStokes.cu @@ -0,0 +1 @@ +#include "navierStokes.h" diff --git a/src/Examples/flows/navierStokes.h b/src/Examples/flows/navierStokes.h new file mode 100644 index 000000000..e8ec526d2 --- /dev/null +++ b/src/Examples/flows/navierStokes.h @@ -0,0 +1,122 @@ +#include +#include +#include +#include +#include +#include +#include "navierStokesProblem.h" +#include "DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h" +#include "DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h" +#include "DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class navierStokesConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntry< String >( "differential-operator", "Choose the differential operator.", "Lax-Friedrichs"); + config.addEntryEnum< String >( "Lax-Friedrichs" ); + config.addEntryEnum< String >( "Steger-Warming" ); + config.addEntryEnum< String >( "VanLeer" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class navierStokesSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + typedef LaxFridrichs< MeshType, Real, Index > ApproximateOperator; + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); + if( differentialOperatorType == "Lax-Friedrichs" ) + typedef LaxFridrichs< MeshType, Real, Index > ApproximateOperator; + else if( differentialOperatorType == "Steger-Warming" ) + typedef StegerWarming< MeshType, Real, Index > ApproximateOperator; + else if( differentialOperatorType == "VanLeer" ) + typedef VanLeer< MeshType, Real, Index > ApproximateOperator; + + /**** + * Resolve the template arguments of your solver here. + * The following code is for the Dirichlet and the Neumann boundary conditions. + * Both can be constant or defined as descrete values of Vector. + */ + + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< navierStokesSetter, navierStokesConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/flows/navierStokesProblem.h b/src/Examples/flows/navierStokesProblem.h new file mode 100644 index 000000000..882de7491 --- /dev/null +++ b/src/Examples/flows/navierStokesProblem.h @@ -0,0 +1,121 @@ +/*************************************************************************** + navierStokesProblem.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include "CompressibleConservativeVariables.h" + + +using namespace TNL::Problems; + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +class navierStokesProblem: + public PDEProblem< Mesh, + Communicator, + typename InviscidOperators::RealType, + typename Mesh::DeviceType, + typename InviscidOperators::IndexType > +{ + public: + + typedef typename InviscidOperators::RealType RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef typename InviscidOperators::IndexType IndexType; + typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; + + typedef Communicator CommunicatorType; + + using typename BaseType::MeshType; + using typename BaseType::MeshPointer; + using typename BaseType::DofVectorType; + using typename BaseType::DofVectorPointer; + static const int Dimensions = Mesh::getMeshDimension(); + + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef SharedPointer< InviscidOperators > InviscidOperatorsPointer; + typedef SharedPointer< BoundaryCondition > BoundaryConditionPointer; + typedef SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; + + static String getType(); + + String getPrologHeader() const; + + void writeProlog( Logger& logger, + const Config::ParameterContainer& parameters ) const; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ); + + bool setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ); + + template< typename Matrix > + bool setupLinearSystem( Matrix& matrix ); + + bool makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ); + + IndexType getDofs() const; + + void bindDofs( DofVectorPointer& dofs ); + + void getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ); + + template< typename Matrix > + void assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs, + Matrix& matrix, + DofVectorPointer& rightHandSide ); + + bool postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ); + + protected: + + InviscidOperatorsPointer inviscidOperatorsPointer; + + BoundaryConditionPointer boundaryConditionPointer; + RightHandSidePointer rightHandSidePointer; + + ConservativeVariablesPointer conservativeVariables, + conservativeVariablesRHS; + + VelocityFieldPointer velocity; + MeshFunctionPointer pressure; + + RealType gamma; + RealType speedIncrement; + RealType cavitySpeed; + RealType speedIncrementUntil; +}; + +} // namespace TNL + +#include "navierStokesProblem_impl.h" + diff --git a/src/Examples/flows/navierStokesProblem_impl.h b/src/Examples/flows/navierStokesProblem_impl.h new file mode 100644 index 000000000..b43fe2ac0 --- /dev/null +++ b/src/Examples/flows/navierStokesProblem_impl.h @@ -0,0 +1,439 @@ +/*************************************************************************** + navierStokesProblem_impl.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "RiemannProblemInitialCondition.h" +#include "CompressibleConservativeVariables.h" +#include "PhysicalVariablesGetter.h" +#include "navierStokesProblem.h" + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getType() +{ + return String( "navierStokesProblem< " ) + Mesh :: getType() + " >"; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getPrologHeader() const +{ + return String( "flow solver" ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const +{ + /**** + * Add data you want to have in the computation report (log) as follows: + * logger.writeParameter< double >( "Parameter description", parameter ); + */ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setup( const Config::ParameterContainer& parameters, + const String& prefix ) +{ + if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || + ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || + ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) + return false; + this->gamma = parameters.getParameter< double >( "gamma" ); + velocity->setMesh( this->getMesh() ); + pressure->setMesh( this->getMesh() ); + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +typename navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >::IndexType +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getDofs() const +{ + /**** + * Return number of DOFs (degrees of freedom) i.e. number + * of unknowns to be resolved by the main solver. + */ + return this->conservativeVariables->getDofs( this->getMesh() ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +bindDofs( DofVectorPointer& dofVector ) +{ + this->conservativeVariables->bind( this->getMesh(), dofVector ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ) +{ + CompressibleConservativeVariables< MeshType > conservativeVariables; + conservativeVariables.bind( this->getMesh(), dofs ); + const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); + this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); + this->speedIncrement = parameters.getParameter< RealType >( "speed-increment" ); + this->cavitySpeed = parameters.getParameter< RealType >( "cavity-speed" ); + if( initialConditionType == "riemann-problem" ) + { + RiemannProblemInitialCondition< MeshType > initialCondition; + if( ! initialCondition.setup( parameters ) ) + return false; + initialCondition.setInitialCondition( conservativeVariables ); + return true; + } + std::cerr << "Unknown initial condition " << initialConditionType << std::endl; + return false; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +bool +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setupLinearSystem( Matrix& matrix ) +{ +/* const IndexType dofs = this->getDofs(); + typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; + CompressedRowLengthsVectorType rowLengths; + if( ! rowLengths.setSize( dofs ) ) + return false; + MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; + matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, + differentialOperator, + boundaryCondition, + rowLengths ); + matrix.setDimensions( dofs, dofs ); + if( ! matrix.setCompressedRowLengths( rowLengths ) ) + return false;*/ + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ) +{ + std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; + + this->bindDofs( dofs ); + PhysicalVariablesGetter< MeshType > physicalVariablesGetter; + physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + + FileName fileName; + fileName.setExtension( "tnl" ); + fileName.setIndex( step ); + fileName.setFileNameBase( "density-" ); + if( ! this->conservativeVariables->getDensity()->save( fileName.getFileName() ) ) + return false; + + fileName.setFileNameBase( "velocity-" ); + if( ! this->velocity->save( fileName.getFileName() ) ) + return false; + + fileName.setFileNameBase( "pressure-" ); + if( ! this->pressure->save( fileName.getFileName() ) ) + return false; + + fileName.setFileNameBase( "energy-" ); + if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) + return false; + + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ) +{ + typedef typename MeshType::Cell Cell; + + /**** + * Bind DOFs + */ + this->conservativeVariables->bind( this->getMesh(), _u ); + this->conservativeVariablesRHS->bind( this->getMesh(), _fu ); + this->velocity->setMesh( this->getMesh() ); + this->pressure->setMesh( this->getMesh() ); + + /**** + * Resolve the physical variables + */ + PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; + physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + + /**** + * Set-up operators + */ + typedef typename InviscidOperators::ContinuityOperatorType ContinuityOperatorType; + typedef typename InviscidOperators::MomentumXOperatorType MomentumXOperatorType; + typedef typename InviscidOperators::MomentumYOperatorType MomentumYOperatorType; + typedef typename InviscidOperators::MomentumZOperatorType MomentumZOperatorType; + typedef typename InviscidOperators::EnergyOperatorType EnergyOperatorType; + + this->inviscidOperatorsPointer->setTau( tau ); + this->inviscidOperatorsPointer->setVelocity( this->velocity ); + this->inviscidOperatorsPointer->setPressure( this->pressure ); + this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); + this->inviscidOperatorsPointer->setGamma( this->gamma ); + + /**** + * Set Up Boundary Conditions + */ + + typedef typename BoundaryCondition::DensityBoundaryConditionsType DensityBoundaryConditionsType; + typedef typename BoundaryCondition::MomentumXBoundaryConditionsType MomentumXBoundaryConditionsType; + typedef typename BoundaryCondition::MomentumYBoundaryConditionsType MomentumYBoundaryConditionsType; + typedef typename BoundaryCondition::MomentumZBoundaryConditionsType MomentumZBoundaryConditionsType; + typedef typename BoundaryCondition::EnergyBoundaryConditionsType EnergyBoundaryConditionsType; + + /**** + * Update Boundary Conditions + */ + if(this->speedIncrementUntil > time ) + { + this->boundaryConditionPointer->setTimestep(this->speedIncrement); + } + else + { + this->boundaryConditionPointer->setTimestep(0); + } + this->boundaryConditionPointer->setSpeed(this->cavitySpeed); + this->boundaryConditionPointer->setCompressibleConservativeVariables(this->conservativeVariables); + this->boundaryConditionPointer->setGamma(this->gamma); + this->boundaryConditionPointer->setPressure(this->pressure); + + /**** + * Continuity equation + */ + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, ContinuityOperatorType, DensityBoundaryConditionsType, RightHandSide > explicitUpdaterContinuity; + explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); + explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer->getDensityBoundaryCondition() ); + explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); + explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getDensity(), + this->conservativeVariablesRHS->getDensity() ); + + /**** + * Momentum equations + */ + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumXOperatorType, MomentumXBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumX; + explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); + explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer->getMomentumXBoundaryCondition() ); + explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); + explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); + + if( Dimensions > 1 ) + { + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumYOperatorType, MomentumYBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumY; + explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); + explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer->getMomentumYBoundaryCondition() ); + explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); + explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); + } + + if( Dimensions > 2 ) + { + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, MomentumZBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumZ; + explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); + explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer->getMomentumZBoundaryCondition() ); + explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); + explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); + } + + + /**** + * Energy equation + */ + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, EnergyOperatorType, EnergyBoundaryConditionsType, RightHandSide > explicitUpdaterEnergy; + explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); + explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer->getEnergyBoundaryCondition() ); + explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); + explicitUpdaterEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getEnergy(), // uRhoVelocityX, + this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); + + /*this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); + this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); + this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); + getchar();*/ + +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +void +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + Matrix& matrix, + DofVectorPointer& b ) +{ +/* LinearSystemAssembler< Mesh, + MeshFunctionType, + InviscidOperators, + BoundaryCondition, + RightHandSide, + BackwardTimeDiscretisation, + Matrix, + DofVectorType > systemAssembler; + + MeshFunction< Mesh > u( mesh, _u ); + systemAssembler.template assembly< typename Mesh::Cell >( time, + tau, + this->differentialOperator, + this->boundaryCondition, + this->rightHandSide, + u, + matrix, + b );*/ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ) +{ + /* + typedef typename MeshType::Cell Cell; + int count = mesh->template getEntitiesCount< Cell >()/4; + //bind _u + this->_uRho.bind( *dofs, 0, count); + this->_uRhoVelocityX.bind( *dofs, count, count); + this->_uRhoVelocityY.bind( *dofs, 2 * count, count); + this->_uEnergy.bind( *dofs, 3 * count, count); + + MeshFunctionType velocity( mesh, this->velocity ); + MeshFunctionType velocityX( mesh, this->velocityX ); + MeshFunctionType velocityY( mesh, this->velocityY ); + MeshFunctionType pressure( mesh, this->pressure ); + MeshFunctionType uRho( mesh, _uRho ); + MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); + MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); + MeshFunctionType uEnergy( mesh, _uEnergy ); + //Generating differential operators + Velocity euler2DVelocity; + VelocityX euler2DVelocityX; + VelocityY euler2DVelocityY; + Pressure euler2DPressure; + + //velocityX + euler2DVelocityX.setRhoVelX(uRhoVelocityX); + euler2DVelocityX.setRho(uRho); +// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; +// velocityX = OFVelocityX; + + //velocityY + euler2DVelocityY.setRhoVelY(uRhoVelocityY); + euler2DVelocityY.setRho(uRho); +// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; +// velocityY = OFVelocityY; + + //velocity + euler2DVelocity.setVelX(velocityX); + euler2DVelocity.setVelY(velocityY); +// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; +// velocity = OFVelocity; + + //pressure + euler2DPressure.setGamma(gamma); + euler2DPressure.setVelocity(velocity); + euler2DPressure.setEnergy(uEnergy); + euler2DPressure.setRho(uRho); +// OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure; +// pressure = OFPressure; + */ + return true; +} + +} // namespace TNL + diff --git a/src/Examples/flows/run-euler b/src/Examples/flows/run-euler new file mode 100644 index 000000000..9ebf9cbb5 --- /dev/null +++ b/src/Examples/flows/run-euler @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-init --test-function sin-wave \ + --output-file init.tnl +tnl-euler-2d --initial-condition riemann-problem \ + --discontinuity-placement-0 0.3 \ + --discontinuity-placement-1 0.3 \ + --discontinuity-placement-2 0.3 \ + --time-discretisation explicit \ + --boundary-conditions-type neumann \ + --boundary-conditions-constant 0 \ + --discrete-solver euler \ + --time-step 0.0001 \ + --snapshot-period 0.01 \ + --final-time 1.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/flows/run-navier-stokes b/src/Examples/flows/run-navier-stokes new file mode 100644 index 000000000..9ebf9cbb5 --- /dev/null +++ b/src/Examples/flows/run-navier-stokes @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-init --test-function sin-wave \ + --output-file init.tnl +tnl-euler-2d --initial-condition riemann-problem \ + --discontinuity-placement-0 0.3 \ + --discontinuity-placement-1 0.3 \ + --discontinuity-placement-2 0.3 \ + --time-discretisation explicit \ + --boundary-conditions-type neumann \ + --boundary-conditions-constant 0 \ + --discrete-solver euler \ + --time-step 0.0001 \ + --snapshot-period 0.01 \ + --final-time 1.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/inviscid-flow-sw/eulerProblem.h b/src/Examples/inviscid-flow-sw/eulerProblem.h index a91e56176..02b99cd83 100644 --- a/src/Examples/inviscid-flow-sw/eulerProblem.h +++ b/src/Examples/inviscid-flow-sw/eulerProblem.h @@ -23,8 +23,8 @@ namespace TNL { template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > + typename Communicator, + typename InviscidOperators > class eulerProblem: public PDEProblem< Mesh, Communicator, @@ -39,11 +39,12 @@ class eulerProblem: typedef typename InviscidOperators::IndexType IndexType; typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; + typedef Communicator CommunicatorType; + using typename BaseType::MeshType; using typename BaseType::MeshPointer; using typename BaseType::DofVectorType; using typename BaseType::DofVectorPointer; - static const int Dimensions = Mesh::getMeshDimension(); typedef Functions::MeshFunction< Mesh > MeshFunctionType; @@ -57,7 +58,7 @@ class eulerProblem: typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; using CommunicatorType = Communicator; - static String getTypeStatic(); + static String getType(); String getPrologHeader() const; diff --git a/src/Examples/inviscid-flow-sw/eulerProblem_impl.h b/src/Examples/inviscid-flow-sw/eulerProblem_impl.h index e0382e9c2..349fe7e19 100644 --- a/src/Examples/inviscid-flow-sw/eulerProblem_impl.h +++ b/src/Examples/inviscid-flow-sw/eulerProblem_impl.h @@ -33,11 +33,11 @@ namespace TNL { template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > + typename Communicator, + typename InviscidOperators > String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getTypeStatic() +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getType() { return String( "eulerProblem< " ) + Mesh :: getTypeStatic() + " >"; } @@ -45,10 +45,10 @@ getTypeStatic() template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > + typename Communicator, + typename InviscidOperators > String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: getPrologHeader() const { return String( "Inviscid flow solver" ); @@ -57,10 +57,6 @@ getPrologHeader() const template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const { /**** @@ -72,10 +68,10 @@ writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) cons template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: + typename Communicator, + typename InviscidOperators > +void +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: setup( const Config::ParameterContainer& parameters, const String& prefix ) { @@ -92,11 +88,10 @@ setup( const Config::ParameterContainer& parameters, template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > -typename eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >::IndexType -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getDofs() const + typename Communicator, + typename InviscidOperators > +bool +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: { /**** * Return number of DOFs (degrees of freedom) i.e. number @@ -108,10 +103,11 @@ getDofs() const template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: + typename Communicator, + typename InviscidOperators > +typename eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >::IndexType +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getDofs( ) const bindDofs( DofVectorPointer& dofVector ) { this->conservativeVariables->bind( this->getMesh(), dofVector ); @@ -120,10 +116,6 @@ bindDofs( DofVectorPointer& dofVector ) template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: setInitialCondition( const Config::ParameterContainer& parameters, DofVectorPointer& dofs ) { @@ -145,14 +137,13 @@ setInitialCondition( const Config::ParameterContainer& parameters, template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > - template< typename Matrix > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: + typename Communicator, + typename InviscidOperators > +void +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: setupLinearSystem( Matrix& matrix ) { -/* const IndexType dofs = this->getDofs( mesh ); +/* const IndexType dofs = this->getDofs(); typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; CompressedRowLengthsVectorType rowLengths; if( ! rowLengths.setSize( dofs ) ) @@ -171,10 +162,10 @@ setupLinearSystem( Matrix& matrix ) template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > + typename Communicator, + typename InviscidOperators > bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: makeSnapshot( const RealType& time, const IndexType& step, DofVectorPointer& dofs ) @@ -210,10 +201,11 @@ makeSnapshot( const RealType& time, template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +bool +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: getExplicitUpdate( const RealType& time, const RealType& tau, DofVectorPointer& _u, @@ -225,13 +217,11 @@ getExplicitUpdate( const RealType& time, /**** * Bind DOFs */ - this->conservativeVariables->bind( mesh, _u ); - this->conservativeVariablesRHS->bind( mesh, _fu ); - this->velocity->setMesh( mesh ); - this->pressure->setMesh( mesh ); + this->conservativeVariables->bind( this->getMesh(), _u ); + this->conservativeVariablesRHS->bind( this->getMesh(), _fu ); + this->velocity->setMesh( this->getMesh() ); + this->pressure->setMesh( this->getMesh() ); -// this->pressure->write( "pressure1", "gnuplot" ); -// getchar(); /**** * Resolve the physical variables */ @@ -263,10 +253,10 @@ getExplicitUpdate( const RealType& time, explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer ); explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterContinuity.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - this->conservativeVariables->getDensity(), - this->conservativeVariablesRHS->getDensity() ); + typename Communicator, + typename InviscidOperators > +bool +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: /**** * Momentum equations @@ -275,10 +265,10 @@ getExplicitUpdate( const RealType& time, explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer ); explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumX.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); + typename Communicator, + typename InviscidOperators > +void +eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: if( Dimensions > 1 ) { @@ -286,22 +276,13 @@ getExplicitUpdate( const RealType& time, explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer ); explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumY.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); } - if( Dimensions > 2 ) - { + if( Dimensions > 2 ) { Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumZ; explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer ); explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumZ.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); } @@ -312,10 +293,9 @@ getExplicitUpdate( const RealType& time, explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer ); explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterEnergy.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - this->conservativeVariablesRHS->getEnergy(), // uRhoVelocityX, - this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); + explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getDensity(), + this->conservativeVariablesRHS->getDensity() ); /* this->pressure->write( "pressure3", "gnuplot" ); getchar(); @@ -329,11 +309,9 @@ getExplicitUpdate( const RealType& time, template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > - template< typename Matrix > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: + explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); assemblyLinearSystem( const RealType& time, const RealType& tau, DofVectorPointer& _u, @@ -364,10 +342,9 @@ assemblyLinearSystem( const RealType& time, template< typename Mesh, typename BoundaryCondition, typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: + explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); postIterate( const RealType& time, const RealType& tau, DofVectorPointer& dofs ) @@ -426,3 +403,6 @@ postIterate( const RealType& time, } // namespace TNL + explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); diff --git a/src/Examples/inviscid-flow-vl/eulerBuildConfigTag.h b/src/Examples/inviscid-flow-vl/eulerBuildConfigTag.h index 4b5d7d638..073b6fb53 100644 --- a/src/Examples/inviscid-flow-vl/eulerBuildConfigTag.h +++ b/src/Examples/inviscid-flow-vl/eulerBuildConfigTag.h @@ -20,6 +20,20 @@ template<> struct ConfigTagReal< eulerBuildConfigTag, long double > { enum { ena template<> struct ConfigTagIndex< eulerBuildConfigTag, short int >{ enum { enabled = false }; }; template<> struct ConfigTagIndex< eulerBuildConfigTag, long int >{ enum { enabled = false }; }; +//template< int Dimension > struct ConfigTagDimension< eulerBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; + +/**** + * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. + */ +/* +template< int Dimension, typename Real, typename Device, typename Index > + struct ConfigTagMesh< eulerBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > + { enum { enabled = ConfigTagDimension< eulerBuildConfigTag, Dimension >::enabled && + ConfigTagReal< eulerBuildConfigTag, Real >::enabled && + ConfigTagDevice< eulerBuildConfigTag, Device >::enabled && + ConfigTagIndex< eulerBuildConfigTag, Index >::enabled }; }; +*/ + /**** * Please, chose your preferred time discretisation here. */ @@ -53,4 +67,4 @@ template<> struct GridIndexTag< eulerBuildConfigTag, long int >{ enum { enabled } // namespace BuildConfigTags } // namespace Meshes -} // namespace TNL \ No newline at end of file +} // namespace TNL diff --git a/src/Examples/inviscid-flow/eulerBuildConfigTag.h b/src/Examples/inviscid-flow/eulerBuildConfigTag.h index fec6d0fe7..872b4e17a 100644 --- a/src/Examples/inviscid-flow/eulerBuildConfigTag.h +++ b/src/Examples/inviscid-flow/eulerBuildConfigTag.h @@ -22,6 +22,18 @@ template<> struct ConfigTagReal< eulerBuildConfigTag, long double > { enum { ena template<> struct ConfigTagIndex< eulerBuildConfigTag, short int >{ enum { enabled = false }; }; template<> struct ConfigTagIndex< eulerBuildConfigTag, long int >{ enum { enabled = false }; }; +//template< int Dimension > struct ConfigTagDimension< eulerBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; + +/**** + * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. + */ +/*template< int Dimension, typename Real, typename Device, typename Index > + struct ConfigTagMesh< eulerBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > + { enum { enabled = ConfigTagDimension< eulerBuildConfigTag, Dimension >::enabled && + ConfigTagReal< eulerBuildConfigTag, Real >::enabled && + ConfigTagDevice< eulerBuildConfigTag, Device >::enabled && + ConfigTagIndex< eulerBuildConfigTag, Index >::enabled }; }; +*/ /**** * Please, chose your preferred time discretisation here. */ diff --git a/src/Examples/transport-equation/transportEquationProblem.h b/src/Examples/transport-equation/transportEquationProblem.h index b6aa381d5..2b8b58fff 100644 --- a/src/Examples/transport-equation/transportEquationProblem.h +++ b/src/Examples/transport-equation/transportEquationProblem.h @@ -50,7 +50,7 @@ public PDEProblem< Mesh, using typename BaseType::MeshPointer; using typename BaseType::DofVectorType; using typename BaseType::DofVectorPointer; - + static String getType(); String getPrologHeader() const; -- GitLab From e7846dad43f176049c28acd05063bbd5b74896ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Wed, 10 Oct 2018 19:30:21 +0200 Subject: [PATCH 02/28] removed solitare flow solvers for Euler and Navier-Stokes equations --- .../flow-sw/BoundaryConditionsBoiler.h | 137 -- .../flow-sw/BoundaryConditionsCavity.h | 137 -- .../CompressibleConservativeVariables.h | 147 -- .../flow-sw/DensityBoundaryConditionBoiler.h | 542 ------- .../flow-sw/DensityBoundaryConditionCavity.h | 536 ------- .../flow-sw/EnergyBoundaryConditionBoiler.h | 854 ---------- .../flow-sw/EnergyBoundaryConditionCavity.h | 673 -------- src/Examples/flow-sw/LaxFridrichs.h | 141 -- src/Examples/flow-sw/LaxFridrichsContinuity.h | 288 ---- src/Examples/flow-sw/LaxFridrichsEnergy.h | 309 ---- .../flow-sw/LaxFridrichsMomentumBase.h | 68 - src/Examples/flow-sw/LaxFridrichsMomentumX.h | 276 ---- src/Examples/flow-sw/LaxFridrichsMomentumY.h | 260 --- src/Examples/flow-sw/LaxFridrichsMomentumZ.h | 240 --- .../MomentumXBoundaryConditionBoiler.h | 594 ------- .../MomentumXBoundaryConditionCavity.h | 570 ------- .../MomentumYBoundaryConditionBoiler.h | 588 ------- .../MomentumYBoundaryConditionCavity.h | 564 ------- .../MomentumZBoundaryConditionBoiler.h | 563 ------- .../MomentumZBoundaryConditionCavity.h | 554 ------- .../flow-sw/PhysicalVariablesGetter.h | 122 -- .../flow-sw/RiemannProblemInitialCondition.h | 1417 ----------------- src/Examples/flow-sw/Upwind.h | 158 -- src/Examples/flow-sw/UpwindContinuity.h | 383 ----- src/Examples/flow-sw/UpwindMomentumX.h | 433 ----- src/Examples/flow-sw/UpwindMomentumY.h | 403 ----- src/Examples/flow-sw/UpwindMomentumZ.h | 338 ---- src/Examples/flow-sw/navierStokes.cpp | 1 - src/Examples/flow-sw/navierStokes.cu | 1 - src/Examples/flow-sw/navierStokes.h | 107 -- .../flow-sw/navierStokesBuildConfigTag.h | 74 - .../flow-sw/navierStokesProblem_impl.h | 458 ------ src/Examples/flow-sw/navierStokesRhs.h | 35 - src/Examples/flow-sw/run-navier-stokes-sw | 25 - .../flow-vl/BoundaryConditionsBoiler.h | 137 -- .../flow-vl/BoundaryConditionsCavity.h | 137 -- src/Examples/flow-vl/CMakeLists.txt | 21 - .../CompressibleConservativeVariables.h | 147 -- .../flow-vl/DensityBoundaryConditionBoiler.h | 542 ------- .../flow-vl/EnergyBoundaryConditionBoiler.h | 854 ---------- src/Examples/flow-vl/LaxFridrichs.h | 141 -- src/Examples/flow-vl/LaxFridrichsContinuity.h | 288 ---- src/Examples/flow-vl/LaxFridrichsEnergy.h | 309 ---- .../flow-vl/LaxFridrichsMomentumBase.h | 68 - src/Examples/flow-vl/LaxFridrichsMomentumX.h | 276 ---- src/Examples/flow-vl/LaxFridrichsMomentumY.h | 260 --- src/Examples/flow-vl/LaxFridrichsMomentumZ.h | 240 --- .../MomentumXBoundaryConditionBoiler.h | 594 ------- .../MomentumXBoundaryConditionCavity.h | 570 ------- .../MomentumYBoundaryConditionBoiler.h | 588 ------- .../MomentumYBoundaryConditionCavity.h | 564 ------- .../MomentumZBoundaryConditionBoiler.h | 563 ------- .../MomentumZBoundaryConditionCavity.h | 554 ------- .../flow-vl/PhysicalVariablesGetter.h | 122 -- src/Examples/flow-vl/UpwindContinuity.h | 385 ----- src/Examples/flow-vl/UpwindEnergy.h | 683 -------- src/Examples/flow-vl/UpwindMomentumBase.h | 137 -- src/Examples/flow-vl/navierStokes.cpp | 1 - src/Examples/flow-vl/navierStokes.cu | 1 - .../flow-vl/navierStokesBuildConfigTag.h | 74 - src/Examples/flow-vl/navierStokesProblem.h | 128 -- src/Examples/flow-vl/navierStokesRhs.h | 35 - src/Examples/flow-vl/run-navier-stokes-vl | 25 - src/Examples/flow/CMakeLists.txt | 21 - .../flow/CompressibleConservativeVariables.h | 147 -- .../flow/DensityBoundaryConditionCavity.h | 536 ------- .../flow/EnergyBoundaryConditionCavity.h | 673 -------- src/Examples/flow/LaxFridrichs.h | 148 -- src/Examples/flow/LaxFridrichsContinuity.h | 290 ---- .../flow/LaxFridrichsContinuityEuler.h | 290 ---- src/Examples/flow/LaxFridrichsEnergy.h | 518 ------ src/Examples/flow/LaxFridrichsEnergyEuler.h | 309 ---- src/Examples/flow/LaxFridrichsEuler.h | 141 -- src/Examples/flow/LaxFridrichsMomentumBase.h | 73 - .../flow/LaxFridrichsMomentumBaseEuler.h | 68 - src/Examples/flow/LaxFridrichsMomentumX.h | 383 ----- .../flow/LaxFridrichsMomentumXEuler.h | 276 ---- src/Examples/flow/LaxFridrichsMomentumY.h | 363 ----- .../flow/LaxFridrichsMomentumYEuler.h | 260 --- src/Examples/flow/LaxFridrichsMomentumZ.h | 314 ---- .../flow/LaxFridrichsMomentumZEuler.h | 240 --- src/Examples/flow/PhysicalVariablesGetter.h | 122 -- .../flow/RiemannProblemInitialCondition.h | 1413 ---------------- src/Examples/flow/navierStokes.h | 108 -- src/Examples/flow/navierStokesProblem.h | 128 -- src/Examples/flow/navierStokesProblem_impl.h | 464 ------ src/Examples/flow/run-navier-stokes | 25 - src/Examples/inviscid-flow-sw/CMakeLists.txt | 21 - .../CompressibleConservativeVariables.h | 147 -- src/Examples/inviscid-flow-sw/LaxFridrichs.h | 141 -- .../inviscid-flow-sw/LaxFridrichsContinuity.h | 288 ---- .../inviscid-flow-sw/LaxFridrichsEnergy.h | 309 ---- .../LaxFridrichsMomentumBase.h | 68 - .../inviscid-flow-sw/LaxFridrichsMomentumX.h | 276 ---- .../inviscid-flow-sw/LaxFridrichsMomentumY.h | 260 --- .../inviscid-flow-sw/LaxFridrichsMomentumZ.h | 240 --- .../PhysicalVariablesGetter.h | 122 -- .../RiemannProblemInitialCondition.h | 1417 ----------------- src/Examples/inviscid-flow-sw/Upwind.h | 151 -- src/Examples/inviscid-flow-sw/UpwindEnergy.h | 542 ------- .../inviscid-flow-sw/UpwindMomentumBase.h | 134 -- .../inviscid-flow-sw/UpwindMomentumX.h | 342 ---- .../inviscid-flow-sw/UpwindMomentumY.h | 318 ---- .../inviscid-flow-sw/UpwindMomentumZ.h | 276 ---- src/Examples/inviscid-flow-sw/euler.cpp | 1 - src/Examples/inviscid-flow-sw/euler.cu | 1 - src/Examples/inviscid-flow-sw/euler.h | 116 -- .../inviscid-flow-sw/eulerBuildConfigTag.h | 56 - src/Examples/inviscid-flow-sw/eulerProblem.h | 126 -- .../inviscid-flow-sw/eulerProblem_impl.h | 408 ----- src/Examples/inviscid-flow-sw/eulerRhs.h | 35 - src/Examples/inviscid-flow-sw/run-euler-sw | 25 - src/Examples/inviscid-flow-vl/CMakeLists.txt | 21 - src/Examples/inviscid-flow-vl/LaxFridrichs.h | 141 -- .../inviscid-flow-vl/LaxFridrichsContinuity.h | 288 ---- .../inviscid-flow-vl/LaxFridrichsEnergy.h | 309 ---- .../LaxFridrichsMomentumBase.h | 68 - .../inviscid-flow-vl/LaxFridrichsMomentumX.h | 276 ---- .../inviscid-flow-vl/LaxFridrichsMomentumY.h | 260 --- .../inviscid-flow-vl/LaxFridrichsMomentumZ.h | 240 --- .../RiemannProblemInitialCondition.h | 1417 ----------------- src/Examples/inviscid-flow-vl/Upwind.h | 151 -- .../inviscid-flow-vl/UpwindContinuity.h | 378 ----- src/Examples/inviscid-flow-vl/UpwindEnergy.h | 507 ------ .../inviscid-flow-vl/UpwindMomentumBase.h | 130 -- .../inviscid-flow-vl/UpwindMomentumX.h | 342 ---- .../inviscid-flow-vl/UpwindMomentumY.h | 318 ---- .../inviscid-flow-vl/UpwindMomentumZ.h | 276 ---- src/Examples/inviscid-flow-vl/euler.cpp | 1 - src/Examples/inviscid-flow-vl/euler.cu | 1 - src/Examples/inviscid-flow-vl/euler.h | 116 -- .../inviscid-flow-vl/eulerBuildConfigTag.h | 70 - src/Examples/inviscid-flow-vl/eulerProblem.h | 125 -- .../inviscid-flow-vl/eulerProblem_impl.h | 428 ----- src/Examples/inviscid-flow-vl/eulerRhs.h | 35 - src/Examples/inviscid-flow-vl/run-euler-vl | 25 - .../1d/MyMixedBoundaryConditions.h | 152 -- .../1d/MyNeumannBoundaryConditions.h | 152 -- .../inviscid-flow/1d/tnl-run-euler-1d | 25 - .../inviscid-flow/2d/Euler2DVelXGetter.h | 56 - .../2d/MyMixedBoundaryConditions.h | 175 -- .../2d/MyNeumannBoundaryConditions.h | 157 -- .../inviscid-flow/2d/tnl-run-euler-2d | 41 - src/Examples/inviscid-flow/3d/CMakeLists.txt | 21 - .../inviscid-flow/3d/Euler2DVelXGetter.h | 56 - .../inviscid-flow/3d/EulerPressureGetter.h | 72 - .../inviscid-flow/3d/EulerVelGetter.h | 62 - .../inviscid-flow/3d/LaxFridrichs3D.h | 41 - .../3d/LaxFridrichsContinuity_impl .h | 350 ---- .../inviscid-flow/3d/LaxFridrichsEnergy.h | 237 --- .../inviscid-flow/3d/LaxFridrichsMomentumX.h | 237 --- .../inviscid-flow/3d/LaxFridrichsMomentumZ.h | 236 --- .../3d/MyMixedBoundaryConditions.h | 175 -- .../3d/MyNeumannBoundaryConditions.h | 157 -- src/Examples/inviscid-flow/3d/euler-cuda.cu | 1 - src/Examples/inviscid-flow/3d/euler.cpp | 1 - src/Examples/inviscid-flow/3d/euler.h | 169 -- .../inviscid-flow/3d/eulerBuildConfigTag.h | 52 - src/Examples/inviscid-flow/3d/eulerProblem.h | 119 -- .../inviscid-flow/3d/eulerProblem_impl.h | 579 ------- src/Examples/inviscid-flow/3d/eulerRhs.h | 35 - src/Examples/inviscid-flow/3d/run-euler | 19 - .../inviscid-flow/3d/tnl-run-euler-2d | 33 - src/Examples/inviscid-flow/CMakeLists.txt | 23 - .../RiemannProblemInitialCondition.h | 1417 ----------------- src/Examples/inviscid-flow/euler.cpp | 1 - src/Examples/inviscid-flow/euler.cu | 1 - src/Examples/inviscid-flow/euler.h | 120 -- .../inviscid-flow/eulerBuildConfigTag.h | 72 - src/Examples/inviscid-flow/eulerProblem.h | 121 -- .../inviscid-flow/eulerProblem_impl.h | 425 ----- src/Examples/inviscid-flow/eulerRhs.h | 35 - 172 files changed, 45118 deletions(-) delete mode 100644 src/Examples/flow-sw/BoundaryConditionsBoiler.h delete mode 100644 src/Examples/flow-sw/BoundaryConditionsCavity.h delete mode 100644 src/Examples/flow-sw/CompressibleConservativeVariables.h delete mode 100644 src/Examples/flow-sw/DensityBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow-sw/DensityBoundaryConditionCavity.h delete mode 100644 src/Examples/flow-sw/EnergyBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow-sw/EnergyBoundaryConditionCavity.h delete mode 100644 src/Examples/flow-sw/LaxFridrichs.h delete mode 100644 src/Examples/flow-sw/LaxFridrichsContinuity.h delete mode 100644 src/Examples/flow-sw/LaxFridrichsEnergy.h delete mode 100644 src/Examples/flow-sw/LaxFridrichsMomentumBase.h delete mode 100644 src/Examples/flow-sw/LaxFridrichsMomentumX.h delete mode 100644 src/Examples/flow-sw/LaxFridrichsMomentumY.h delete mode 100644 src/Examples/flow-sw/LaxFridrichsMomentumZ.h delete mode 100644 src/Examples/flow-sw/MomentumXBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow-sw/MomentumXBoundaryConditionCavity.h delete mode 100644 src/Examples/flow-sw/MomentumYBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow-sw/MomentumYBoundaryConditionCavity.h delete mode 100644 src/Examples/flow-sw/MomentumZBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow-sw/MomentumZBoundaryConditionCavity.h delete mode 100644 src/Examples/flow-sw/PhysicalVariablesGetter.h delete mode 100644 src/Examples/flow-sw/RiemannProblemInitialCondition.h delete mode 100644 src/Examples/flow-sw/Upwind.h delete mode 100644 src/Examples/flow-sw/UpwindContinuity.h delete mode 100644 src/Examples/flow-sw/UpwindMomentumX.h delete mode 100644 src/Examples/flow-sw/UpwindMomentumY.h delete mode 100644 src/Examples/flow-sw/UpwindMomentumZ.h delete mode 100644 src/Examples/flow-sw/navierStokes.cpp delete mode 100644 src/Examples/flow-sw/navierStokes.cu delete mode 100644 src/Examples/flow-sw/navierStokes.h delete mode 100644 src/Examples/flow-sw/navierStokesBuildConfigTag.h delete mode 100644 src/Examples/flow-sw/navierStokesProblem_impl.h delete mode 100644 src/Examples/flow-sw/navierStokesRhs.h delete mode 100644 src/Examples/flow-sw/run-navier-stokes-sw delete mode 100644 src/Examples/flow-vl/BoundaryConditionsBoiler.h delete mode 100644 src/Examples/flow-vl/BoundaryConditionsCavity.h delete mode 100644 src/Examples/flow-vl/CMakeLists.txt delete mode 100644 src/Examples/flow-vl/CompressibleConservativeVariables.h delete mode 100644 src/Examples/flow-vl/DensityBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow-vl/EnergyBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow-vl/LaxFridrichs.h delete mode 100644 src/Examples/flow-vl/LaxFridrichsContinuity.h delete mode 100644 src/Examples/flow-vl/LaxFridrichsEnergy.h delete mode 100644 src/Examples/flow-vl/LaxFridrichsMomentumBase.h delete mode 100644 src/Examples/flow-vl/LaxFridrichsMomentumX.h delete mode 100644 src/Examples/flow-vl/LaxFridrichsMomentumY.h delete mode 100644 src/Examples/flow-vl/LaxFridrichsMomentumZ.h delete mode 100644 src/Examples/flow-vl/MomentumXBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow-vl/MomentumXBoundaryConditionCavity.h delete mode 100644 src/Examples/flow-vl/MomentumYBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow-vl/MomentumYBoundaryConditionCavity.h delete mode 100644 src/Examples/flow-vl/MomentumZBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow-vl/MomentumZBoundaryConditionCavity.h delete mode 100644 src/Examples/flow-vl/PhysicalVariablesGetter.h delete mode 100644 src/Examples/flow-vl/UpwindContinuity.h delete mode 100644 src/Examples/flow-vl/UpwindEnergy.h delete mode 100644 src/Examples/flow-vl/UpwindMomentumBase.h delete mode 100644 src/Examples/flow-vl/navierStokes.cpp delete mode 100644 src/Examples/flow-vl/navierStokes.cu delete mode 100644 src/Examples/flow-vl/navierStokesBuildConfigTag.h delete mode 100644 src/Examples/flow-vl/navierStokesProblem.h delete mode 100644 src/Examples/flow-vl/navierStokesRhs.h delete mode 100644 src/Examples/flow-vl/run-navier-stokes-vl delete mode 100644 src/Examples/flow/CMakeLists.txt delete mode 100644 src/Examples/flow/CompressibleConservativeVariables.h delete mode 100644 src/Examples/flow/DensityBoundaryConditionCavity.h delete mode 100644 src/Examples/flow/EnergyBoundaryConditionCavity.h delete mode 100644 src/Examples/flow/LaxFridrichs.h delete mode 100644 src/Examples/flow/LaxFridrichsContinuity.h delete mode 100644 src/Examples/flow/LaxFridrichsContinuityEuler.h delete mode 100644 src/Examples/flow/LaxFridrichsEnergy.h delete mode 100644 src/Examples/flow/LaxFridrichsEnergyEuler.h delete mode 100644 src/Examples/flow/LaxFridrichsEuler.h delete mode 100644 src/Examples/flow/LaxFridrichsMomentumBase.h delete mode 100644 src/Examples/flow/LaxFridrichsMomentumBaseEuler.h delete mode 100644 src/Examples/flow/LaxFridrichsMomentumX.h delete mode 100644 src/Examples/flow/LaxFridrichsMomentumXEuler.h delete mode 100644 src/Examples/flow/LaxFridrichsMomentumY.h delete mode 100644 src/Examples/flow/LaxFridrichsMomentumYEuler.h delete mode 100644 src/Examples/flow/LaxFridrichsMomentumZ.h delete mode 100644 src/Examples/flow/LaxFridrichsMomentumZEuler.h delete mode 100644 src/Examples/flow/PhysicalVariablesGetter.h delete mode 100644 src/Examples/flow/RiemannProblemInitialCondition.h delete mode 100644 src/Examples/flow/navierStokes.h delete mode 100644 src/Examples/flow/navierStokesProblem.h delete mode 100644 src/Examples/flow/navierStokesProblem_impl.h delete mode 100644 src/Examples/flow/run-navier-stokes delete mode 100644 src/Examples/inviscid-flow-sw/CMakeLists.txt delete mode 100644 src/Examples/inviscid-flow-sw/CompressibleConservativeVariables.h delete mode 100644 src/Examples/inviscid-flow-sw/LaxFridrichs.h delete mode 100644 src/Examples/inviscid-flow-sw/LaxFridrichsContinuity.h delete mode 100644 src/Examples/inviscid-flow-sw/LaxFridrichsEnergy.h delete mode 100644 src/Examples/inviscid-flow-sw/LaxFridrichsMomentumBase.h delete mode 100644 src/Examples/inviscid-flow-sw/LaxFridrichsMomentumX.h delete mode 100644 src/Examples/inviscid-flow-sw/LaxFridrichsMomentumY.h delete mode 100644 src/Examples/inviscid-flow-sw/LaxFridrichsMomentumZ.h delete mode 100644 src/Examples/inviscid-flow-sw/PhysicalVariablesGetter.h delete mode 100644 src/Examples/inviscid-flow-sw/RiemannProblemInitialCondition.h delete mode 100644 src/Examples/inviscid-flow-sw/Upwind.h delete mode 100644 src/Examples/inviscid-flow-sw/UpwindEnergy.h delete mode 100644 src/Examples/inviscid-flow-sw/UpwindMomentumBase.h delete mode 100644 src/Examples/inviscid-flow-sw/UpwindMomentumX.h delete mode 100644 src/Examples/inviscid-flow-sw/UpwindMomentumY.h delete mode 100644 src/Examples/inviscid-flow-sw/UpwindMomentumZ.h delete mode 100644 src/Examples/inviscid-flow-sw/euler.cpp delete mode 100644 src/Examples/inviscid-flow-sw/euler.cu delete mode 100644 src/Examples/inviscid-flow-sw/euler.h delete mode 100644 src/Examples/inviscid-flow-sw/eulerBuildConfigTag.h delete mode 100644 src/Examples/inviscid-flow-sw/eulerProblem.h delete mode 100644 src/Examples/inviscid-flow-sw/eulerProblem_impl.h delete mode 100644 src/Examples/inviscid-flow-sw/eulerRhs.h delete mode 100644 src/Examples/inviscid-flow-sw/run-euler-sw delete mode 100644 src/Examples/inviscid-flow-vl/CMakeLists.txt delete mode 100644 src/Examples/inviscid-flow-vl/LaxFridrichs.h delete mode 100644 src/Examples/inviscid-flow-vl/LaxFridrichsContinuity.h delete mode 100644 src/Examples/inviscid-flow-vl/LaxFridrichsEnergy.h delete mode 100644 src/Examples/inviscid-flow-vl/LaxFridrichsMomentumBase.h delete mode 100644 src/Examples/inviscid-flow-vl/LaxFridrichsMomentumX.h delete mode 100644 src/Examples/inviscid-flow-vl/LaxFridrichsMomentumY.h delete mode 100644 src/Examples/inviscid-flow-vl/LaxFridrichsMomentumZ.h delete mode 100644 src/Examples/inviscid-flow-vl/RiemannProblemInitialCondition.h delete mode 100644 src/Examples/inviscid-flow-vl/Upwind.h delete mode 100644 src/Examples/inviscid-flow-vl/UpwindContinuity.h delete mode 100644 src/Examples/inviscid-flow-vl/UpwindEnergy.h delete mode 100644 src/Examples/inviscid-flow-vl/UpwindMomentumBase.h delete mode 100644 src/Examples/inviscid-flow-vl/UpwindMomentumX.h delete mode 100644 src/Examples/inviscid-flow-vl/UpwindMomentumY.h delete mode 100644 src/Examples/inviscid-flow-vl/UpwindMomentumZ.h delete mode 100644 src/Examples/inviscid-flow-vl/euler.cpp delete mode 100644 src/Examples/inviscid-flow-vl/euler.cu delete mode 100644 src/Examples/inviscid-flow-vl/euler.h delete mode 100644 src/Examples/inviscid-flow-vl/eulerBuildConfigTag.h delete mode 100644 src/Examples/inviscid-flow-vl/eulerProblem.h delete mode 100644 src/Examples/inviscid-flow-vl/eulerProblem_impl.h delete mode 100644 src/Examples/inviscid-flow-vl/eulerRhs.h delete mode 100644 src/Examples/inviscid-flow-vl/run-euler-vl delete mode 100644 src/Examples/inviscid-flow/1d/MyMixedBoundaryConditions.h delete mode 100644 src/Examples/inviscid-flow/1d/MyNeumannBoundaryConditions.h delete mode 100644 src/Examples/inviscid-flow/1d/tnl-run-euler-1d delete mode 100644 src/Examples/inviscid-flow/2d/Euler2DVelXGetter.h delete mode 100644 src/Examples/inviscid-flow/2d/MyMixedBoundaryConditions.h delete mode 100644 src/Examples/inviscid-flow/2d/MyNeumannBoundaryConditions.h delete mode 100644 src/Examples/inviscid-flow/2d/tnl-run-euler-2d delete mode 100644 src/Examples/inviscid-flow/3d/CMakeLists.txt delete mode 100644 src/Examples/inviscid-flow/3d/Euler2DVelXGetter.h delete mode 100644 src/Examples/inviscid-flow/3d/EulerPressureGetter.h delete mode 100644 src/Examples/inviscid-flow/3d/EulerVelGetter.h delete mode 100644 src/Examples/inviscid-flow/3d/LaxFridrichs3D.h delete mode 100644 src/Examples/inviscid-flow/3d/LaxFridrichsContinuity_impl .h delete mode 100644 src/Examples/inviscid-flow/3d/LaxFridrichsEnergy.h delete mode 100644 src/Examples/inviscid-flow/3d/LaxFridrichsMomentumX.h delete mode 100644 src/Examples/inviscid-flow/3d/LaxFridrichsMomentumZ.h delete mode 100644 src/Examples/inviscid-flow/3d/MyMixedBoundaryConditions.h delete mode 100644 src/Examples/inviscid-flow/3d/MyNeumannBoundaryConditions.h delete mode 100644 src/Examples/inviscid-flow/3d/euler-cuda.cu delete mode 100644 src/Examples/inviscid-flow/3d/euler.cpp delete mode 100644 src/Examples/inviscid-flow/3d/euler.h delete mode 100644 src/Examples/inviscid-flow/3d/eulerBuildConfigTag.h delete mode 100644 src/Examples/inviscid-flow/3d/eulerProblem.h delete mode 100644 src/Examples/inviscid-flow/3d/eulerProblem_impl.h delete mode 100644 src/Examples/inviscid-flow/3d/eulerRhs.h delete mode 100644 src/Examples/inviscid-flow/3d/run-euler delete mode 100644 src/Examples/inviscid-flow/3d/tnl-run-euler-2d delete mode 100644 src/Examples/inviscid-flow/CMakeLists.txt delete mode 100644 src/Examples/inviscid-flow/RiemannProblemInitialCondition.h delete mode 100644 src/Examples/inviscid-flow/euler.cpp delete mode 100644 src/Examples/inviscid-flow/euler.cu delete mode 100644 src/Examples/inviscid-flow/euler.h delete mode 100644 src/Examples/inviscid-flow/eulerBuildConfigTag.h delete mode 100644 src/Examples/inviscid-flow/eulerProblem.h delete mode 100644 src/Examples/inviscid-flow/eulerProblem_impl.h delete mode 100644 src/Examples/inviscid-flow/eulerRhs.h diff --git a/src/Examples/flow-sw/BoundaryConditionsBoiler.h b/src/Examples/flow-sw/BoundaryConditionsBoiler.h deleted file mode 100644 index f61f988da..000000000 --- a/src/Examples/flow-sw/BoundaryConditionsBoiler.h +++ /dev/null @@ -1,137 +0,0 @@ -#include - -#include "DensityBoundaryConditionBoiler.h" -#include "MomentumXBoundaryConditionBoiler.h" -#include "MomentumYBoundaryConditionBoiler.h" -#include "MomentumZBoundaryConditionBoiler.h" -#include "EnergyBoundaryConditionBoiler.h" - -namespace TNL { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class BoundaryConditionsBoiler -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef Index IndexType; - typedef Function FunctionType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef typename Mesh::DeviceType DeviceType; - - typedef TNL::Operators::DensityBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; - typedef TNL::Operators::MomentumXBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; - typedef TNL::Operators::MomentumYBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; - typedef TNL::Operators::MomentumZBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; - typedef TNL::Operators::EnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - - typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - return true; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - } - - void setTimestep(const RealType timestep) - { - this->densityBoundaryConditionsPointer->setTimestep(timestep); - this->momentumXBoundaryConditionsPointer->setTimestep(timestep); - this->momentumYBoundaryConditionsPointer->setTimestep(timestep); - this->momentumZBoundaryConditionsPointer->setTimestep(timestep); - this->energyBoundaryConditionsPointer->setTimestep(timestep); - } - - void setGamma(const RealType gamma) - { - this->densityBoundaryConditionsPointer->setGamma(gamma); - this->momentumXBoundaryConditionsPointer->setGamma(gamma); - this->momentumYBoundaryConditionsPointer->setGamma(gamma); - this->momentumZBoundaryConditionsPointer->setGamma(gamma); - this->energyBoundaryConditionsPointer->setGamma(gamma); - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->densityBoundaryConditionsPointer->setPressure(pressure); - this->momentumXBoundaryConditionsPointer->setPressure(pressure); - this->momentumYBoundaryConditionsPointer->setPressure(pressure); - this->momentumZBoundaryConditionsPointer->setPressure(pressure); - this->energyBoundaryConditionsPointer->setPressure(pressure); - } - - void setSpeed(const RealType cavitySpeed) - { - this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - } - - DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() - { - return this->densityBoundaryConditionsPointer; - } - - MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() - { - return this->momentumXBoundaryConditionsPointer; - } - - MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() - { - return this->momentumYBoundaryConditionsPointer; - } - - MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() - { - return this->momentumZBoundaryConditionsPointer; - } - - EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() - { - return this->energyBoundaryConditionsPointer; - } - - - protected: - DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; - MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; - MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; - MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; - EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; - -}; - -} //namespace TNL diff --git a/src/Examples/flow-sw/BoundaryConditionsCavity.h b/src/Examples/flow-sw/BoundaryConditionsCavity.h deleted file mode 100644 index bbae2d3e9..000000000 --- a/src/Examples/flow-sw/BoundaryConditionsCavity.h +++ /dev/null @@ -1,137 +0,0 @@ -#include - -#include "DensityBoundaryConditionCavity.h" -#include "MomentumXBoundaryConditionCavity.h" -#include "MomentumYBoundaryConditionCavity.h" -#include "MomentumZBoundaryConditionCavity.h" -#include "EnergyBoundaryConditionCavity.h" - -namespace TNL { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class BoundaryConditionsCavity -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef Index IndexType; - typedef Function FunctionType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef typename Mesh::DeviceType DeviceType; - - typedef TNL::Operators::DensityBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; - typedef TNL::Operators::MomentumXBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; - typedef TNL::Operators::MomentumYBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; - typedef TNL::Operators::MomentumZBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; - typedef TNL::Operators::EnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - - typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - return true; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - } - - void setTimestep(const RealType timestep) - { - this->densityBoundaryConditionsPointer->setTimestep(timestep); - this->momentumXBoundaryConditionsPointer->setTimestep(timestep); - this->momentumYBoundaryConditionsPointer->setTimestep(timestep); - this->momentumZBoundaryConditionsPointer->setTimestep(timestep); - this->energyBoundaryConditionsPointer->setTimestep(timestep); - } - - void setGamma(const RealType gamma) - { - this->densityBoundaryConditionsPointer->setGamma(gamma); - this->momentumXBoundaryConditionsPointer->setGamma(gamma); - this->momentumYBoundaryConditionsPointer->setGamma(gamma); - this->momentumZBoundaryConditionsPointer->setGamma(gamma); - this->energyBoundaryConditionsPointer->setGamma(gamma); - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->densityBoundaryConditionsPointer->setPressure(pressure); - this->momentumXBoundaryConditionsPointer->setPressure(pressure); - this->momentumYBoundaryConditionsPointer->setPressure(pressure); - this->momentumZBoundaryConditionsPointer->setPressure(pressure); - this->energyBoundaryConditionsPointer->setPressure(pressure); - } - - void setSpeed(const RealType cavitySpeed) - { - this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - } - - DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() - { - return this->densityBoundaryConditionsPointer; - } - - MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() - { - return this->momentumXBoundaryConditionsPointer; - } - - MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() - { - return this->momentumYBoundaryConditionsPointer; - } - - MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() - { - return this->momentumZBoundaryConditionsPointer; - } - - EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() - { - return this->energyBoundaryConditionsPointer; - } - - - protected: - DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; - MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; - MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; - MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; - EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; - -}; - -} //namespace TNL diff --git a/src/Examples/flow-sw/CompressibleConservativeVariables.h b/src/Examples/flow-sw/CompressibleConservativeVariables.h deleted file mode 100644 index 01e820686..000000000 --- a/src/Examples/flow-sw/CompressibleConservativeVariables.h +++ /dev/null @@ -1,147 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -namespace TNL { - -template< typename Mesh > -class CompressibleConservativeVariables -{ - public: - typedef Mesh MeshType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; - - CompressibleConservativeVariables(){}; - - CompressibleConservativeVariables( const MeshPointer& meshPointer ) - : density( meshPointer ), - momentum( meshPointer ), - //pressure( meshPointer ), - energy( meshPointer ){}; - - void setMesh( const MeshPointer& meshPointer ) - { - this->density->setMesh( meshPointer ); - this->momentum->setMesh( meshPointer ); - //this->pressure.setMesh( meshPointer ); - this->energy->setMesh( meshPointer ); - } - - template< typename Vector > - void bind( const MeshPointer& meshPointer, - const Vector& data, - IndexType offset = 0 ) - { - IndexType currentOffset( offset ); - this->density->bind( meshPointer, data, currentOffset ); - currentOffset += this->density->getDofs( meshPointer ); - for( IndexType i = 0; i < Dimensions; i++ ) - { - ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); - currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); - } - this->energy->bind( meshPointer, data, currentOffset ); - } - - IndexType getDofs( const MeshPointer& meshPointer ) const - { - return this->density->getDofs( meshPointer ) + - this->momentum->getDofs( meshPointer ) + - this->energy->getDofs( meshPointer ); - } - - MeshFunctionPointer& getDensity() - { - return this->density; - } - - const MeshFunctionPointer& getDensity() const - { - return this->density; - } - - void setDensity( MeshFunctionPointer& density ) - { - this->density = density; - } - - MomentumFieldPointer& getMomentum() - { - return this->momentum; - } - - const MomentumFieldPointer& getMomentum() const - { - return this->momentum; - } - - void setMomentum( MomentumFieldPointer& momentum ) - { - this->momentum = momentum; - } - - /*MeshFunctionPointer& getPressure() - { - return this->pressure; - } - - const MeshFunctionPointer& getPressure() const - { - return this->pressure; - } - - void setPressure( MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }*/ - - MeshFunctionPointer& getEnergy() - { - return this->energy; - } - - const MeshFunctionPointer& getEnergy() const - { - return this->energy; - } - - void setEnergy( MeshFunctionPointer& energy ) - { - this->energy = energy; - } - - void getVelocityField( VelocityFieldType& velocityField ) - { - - } - - protected: - - MeshFunctionPointer density; - MomentumFieldPointer momentum; - MeshFunctionPointer energy; - -}; - -} // namespace TN diff --git a/src/Examples/flow-sw/DensityBoundaryConditionBoiler.h b/src/Examples/flow-sw/DensityBoundaryConditionBoiler.h deleted file mode 100644 index 6231f6780..000000000 --- a/src/Examples/flow-sw/DensityBoundaryConditionBoiler.h +++ /dev/null @@ -1,542 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class DensityBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class DensityBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return u[ neighborEntities.template getEntityIndex< 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if (entity.getCoordinates().y() < 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if (entity.getCoordinates().z() < 0.8 * ( entity.getMesh().getDimensions().z() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionBoilers: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-sw/DensityBoundaryConditionCavity.h b/src/Examples/flow-sw/DensityBoundaryConditionCavity.h deleted file mode 100644 index 18eaff110..000000000 --- a/src/Examples/flow-sw/DensityBoundaryConditionCavity.h +++ /dev/null @@ -1,536 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class DensityBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class DensityBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return u[ neighborEntities.template getEntityIndex< 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-sw/EnergyBoundaryConditionBoiler.h b/src/Examples/flow-sw/EnergyBoundaryConditionBoiler.h deleted file mode 100644 index a99fdf015..000000000 --- a/src/Examples/flow-sw/EnergyBoundaryConditionBoiler.h +++ /dev/null @@ -1,854 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class EnergyBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function> -class EnergyBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed - * - this->cavitySpeed - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - * - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - );*/ - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - * - this->cavitySpeed * ( -1 ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - ); - else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - );*/ - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - + - this->cavitySpeed - * - this->cavitySpeed - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - );*/ - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - + 0 - ) - );*/ - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - * - this->cavitySpeed - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - * - this->cavitySpeed * ( -1 ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - * - this->cavitySpeed - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - * - this->cavitySpeed * ( -1 ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) -{ - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * - ( - ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( - this->cavitySpeed - * - this->cavitySpeed - ) - ); - - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-sw/EnergyBoundaryConditionCavity.h b/src/Examples/flow-sw/EnergyBoundaryConditionCavity.h deleted file mode 100644 index 3b49cd56e..000000000 --- a/src/Examples/flow-sw/EnergyBoundaryConditionCavity.h +++ /dev/null @@ -1,673 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class EnergyBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function> -class EnergyBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /* ( (* this->pressure)[ neighborEntities.template getEntityIndex< 1, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - * - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - )*/; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /* ( (* this->pressure)[ neighborEntities.template getEntityIndex< -1, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - )*/; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /* ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 1 >() ] - / ( this->gamma - 1 ) - ) - + 0 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - )*/; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, -1 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - * ( - this->cavitySpeed/* - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 )*/ - * - this->cavitySpeed/* - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 )*/ - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - ); - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - ( this->cavitySpeed - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 ) - ) - * - ( this->cavitySpeed - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 ) - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-sw/LaxFridrichs.h b/src/Examples/flow-sw/LaxFridrichs.h deleted file mode 100644 index c56d20aed..000000000 --- a/src/Examples/flow-sw/LaxFridrichs.h +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - LaxFridrichs.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichs -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef LaxFridrichsContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); - } - - LaxFridrichs() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); - this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); - - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flow-sw/LaxFridrichsContinuity.h b/src/Examples/flow-sw/LaxFridrichsContinuity.h deleted file mode 100644 index 82747cd18..000000000 --- a/src/Examples/flow-sw/LaxFridrichsContinuity.h +++ /dev/null @@ -1,288 +0,0 @@ -/*************************************************************************** - LaxFridrichsContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsContinuityBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - RealType artificialViscosity; -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) - - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse - + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/flow-sw/LaxFridrichsEnergy.h b/src/Examples/flow-sw/LaxFridrichsEnergy.h deleted file mode 100644 index 03019ed23..000000000 --- a/src/Examples/flow-sw/LaxFridrichsEnergy.h +++ /dev/null @@ -1,309 +0,0 @@ -/*************************************************************************** - LaxFridrichsEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east - - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse; - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse - + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) - -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/flow-sw/LaxFridrichsMomentumBase.h b/src/Examples/flow-sw/LaxFridrichsMomentumBase.h deleted file mode 100644 index cc2561748..000000000 --- a/src/Examples/flow-sw/LaxFridrichsMomentumBase.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsMomentumBase() - : artificialViscosity( 1.0 ){}; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flow-sw/LaxFridrichsMomentumX.h b/src/Examples/flow-sw/LaxFridrichsMomentumX.h deleted file mode 100644 index 63def12d3..000000000 --- a/src/Examples/flow-sw/LaxFridrichsMomentumX.h +++ /dev/null @@ -1,276 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - //const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - //const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - //const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - //const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_u[ up ] * velocity_z_up ) - - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-sw/LaxFridrichsMomentumY.h b/src/Examples/flow-sw/LaxFridrichsMomentumY.h deleted file mode 100644 index 8ce42282d..000000000 --- a/src/Examples/flow-sw/LaxFridrichsMomentumY.h +++ /dev/null @@ -1,260 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse - + ( ( rho_v[ up ] * velocity_z_up ) - - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-sw/LaxFridrichsMomentumZ.h b/src/Examples/flow-sw/LaxFridrichsMomentumZ.h deleted file mode 100644 index a67e862ce..000000000 --- a/src/Examples/flow-sw/LaxFridrichsMomentumZ.h +++ /dev/null @@ -1,240 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) - -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) - - ( rho_w[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_w[ north ] * velocity_y_north ) - - ( rho_w[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) - - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-sw/MomentumXBoundaryConditionBoiler.h b/src/Examples/flow-sw/MomentumXBoundaryConditionBoiler.h deleted file mode 100644 index dfe63e076..000000000 --- a/src/Examples/flow-sw/MomentumXBoundaryConditionBoiler.h +++ /dev/null @@ -1,594 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumXBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumXBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - ); - else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - );*/ - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - );*/ - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - ); - else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-sw/MomentumXBoundaryConditionCavity.h b/src/Examples/flow-sw/MomentumXBoundaryConditionCavity.h deleted file mode 100644 index 07abfdbeb..000000000 --- a/src/Examples/flow-sw/MomentumXBoundaryConditionCavity.h +++ /dev/null @@ -1,570 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumXBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumXBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - );*/ - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - * ( - ( this->cavitySpeed/* - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 )*/ - ) - ); - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-sw/MomentumYBoundaryConditionBoiler.h b/src/Examples/flow-sw/MomentumYBoundaryConditionBoiler.h deleted file mode 100644 index 83b6282dd..000000000 --- a/src/Examples/flow-sw/MomentumYBoundaryConditionBoiler.h +++ /dev/null @@ -1,588 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumYBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumYBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - );*/ - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - );*/ - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-sw/MomentumYBoundaryConditionCavity.h b/src/Examples/flow-sw/MomentumYBoundaryConditionCavity.h deleted file mode 100644 index a83dd653f..000000000 --- a/src/Examples/flow-sw/MomentumYBoundaryConditionCavity.h +++ /dev/null @@ -1,564 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumYBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumYBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - );*/ - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - );*/ - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-sw/MomentumZBoundaryConditionBoiler.h b/src/Examples/flow-sw/MomentumZBoundaryConditionBoiler.h deleted file mode 100644 index 9d887857c..000000000 --- a/src/Examples/flow-sw/MomentumZBoundaryConditionBoiler.h +++ /dev/null @@ -1,563 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumZBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumZBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-sw/MomentumZBoundaryConditionCavity.h b/src/Examples/flow-sw/MomentumZBoundaryConditionCavity.h deleted file mode 100644 index 5fe6f22e5..000000000 --- a/src/Examples/flow-sw/MomentumZBoundaryConditionCavity.h +++ /dev/null @@ -1,554 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumZBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumZBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-sw/PhysicalVariablesGetter.h b/src/Examples/flow-sw/PhysicalVariablesGetter.h deleted file mode 100644 index d7eeb7618..000000000 --- a/src/Examples/flow-sw/PhysicalVariablesGetter.h +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { - -template< typename Mesh > -class PhysicalVariablesGetter -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - VelocityGetter( MeshFunctionPointer density, - MeshFunctionPointer momentum ) - : density( density ), momentum( momentum ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) - return 0; - else - return momentum.template getData< DeviceType >()( meshEntity ) / - density.template getData< DeviceType >()( meshEntity ); - } - - protected: - const MeshFunctionPointer density, momentum; - }; - - class PressureGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - PressureGetter( MeshFunctionPointer density, - MeshFunctionPointer energy, - VelocityFieldPointer momentum, - const RealType& gamma ) - : density( density ), energy( energy ), momentum( momentum ), gamma( gamma ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - const RealType e = energy.template getData< DeviceType >()( meshEntity ); - const RealType rho = density.template getData< DeviceType >()( meshEntity ); - const RealType momentumNorm = lpNorm( momentum.template getData< DeviceType >().getVector( meshEntity ), 2.0 ); - if( rho == 0.0 ) - return 0; - else - return ( gamma - 1.0 ) * ( e - 0.5 * momentumNorm * momentumNorm / rho ); - } - - protected: - const MeshFunctionPointer density, energy; - const VelocityFieldPointer momentum; - const RealType gamma; - }; - - - void getVelocity( const ConservativeVariablesPointer& conservativeVariables, - VelocityFieldPointer& velocity ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; - for( int i = 0; i < Dimensions; i++ ) - { - Pointers::SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), - ( *conservativeVariables->getMomentum() )[ i ] ); - evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); - } - } - - void getPressure( const ConservativeVariablesPointer& conservativeVariables, - const RealType& gamma, - MeshFunctionPointer& pressure ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; - Pointers::SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), - conservativeVariables->getEnergy(), - conservativeVariables->getMomentum(), - gamma ); - evaluator.evaluate( pressure, pressureGetter ); - } - -}; - -} //namespace TNL diff --git a/src/Examples/flow-sw/RiemannProblemInitialCondition.h b/src/Examples/flow-sw/RiemannProblemInitialCondition.h deleted file mode 100644 index dfde32625..000000000 --- a/src/Examples/flow-sw/RiemannProblemInitialCondition.h +++ /dev/null @@ -1,1417 +0,0 @@ -/*************************************************************************** - RiemannProblemInitialCondition.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -template -class RiemannProblemInitialConditionSetter -{ - -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 1,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 2,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template< typename Mesh > -class RiemannProblemInitialCondition -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; - - RiemannProblemInitialCondition() - : discontinuityPlacement( 0.5 ), - leftDensity( 1.0 ), rightDensity( 1.0 ), - leftVelocity( -2.0 ), rightVelocity( 2.0 ), - leftPressure( 0.4 ), rightPressure( 0.4 ), - gamma( 1.67 ){} - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "discontinuity-placement-0", "x-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-1", "y-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-2", "z-coordinate of the discontinuity placement.", 0.5 ); -/* - config.addEntry< double >( prefix + "left-density", "Density on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-density", "Density on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-velocity-0", "x-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-1", "y-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-2", "z-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-velocity-0", "x-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-1", "y-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-2", "z-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-pressure", "Pressure on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-pressure", "Pressure on the right side of the discontinuity.", 0.0 ); -*/ - config.addEntry< double >( prefix + "NWU-density", "This sets a value of northwest up density.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-0", "This sets a value of northwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-1", "This sets a value of northwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-2", "This sets a value of northwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-pressure", "This sets a value of northwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWU-density", "This sets a value of southwest up density.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-0", "This sets a value of southwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-1", "This sets a value of southwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-2", "This sets a value of southwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-pressure", "This sets a value of southwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NWD-density", "This sets a value of northwest down density.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-0", "This sets a value of northwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-1", "This sets a value of northwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-2", "This sets a value of northwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-pressure", "This sets a value of northwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWD-density", "This sets a value of southwest down density.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-0", "This sets a value of southwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-1", "This sets a value of southwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-2", "This sets a value of southwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-pressure", "This sets a value of southwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "NEU-density", "This sets a value of northeast up density.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-0", "This sets a value of northeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-1", "This sets a value of northeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-2", "This sets a value of northeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-pressure", "This sets a value of northeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SEU-density", "This sets a value of southeast up density.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-0", "This sets a value of southeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-1", "This sets a value of southeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-2", "This sets a value of southeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-pressure", "This sets a value of southeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NED-density", "This sets a value of northeast down density.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-0", "This sets a value of northeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-1", "This sets a value of northeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-2", "This sets a value of northeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-pressure", "This sets a value of northeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SED-density", "This sets a value of southeast down density.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-0", "This sets a value of southeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-1", "This sets a value of southeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-2", "This sets a value of southeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-pressure", "This sets a value of southeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "gamma", "Gamma in the ideal gas state equation.", 1.4 ); - - config.addEntry< String >( prefix + "initial", " One of predefined initial condition.", "none"); - config.addEntryEnum< String >( "none" ); - config.addEntryEnum< String >( "1D_2" ); - config.addEntryEnum< String >( "1D_3a" ); - config.addEntryEnum< String >( "1D_4" ); - config.addEntryEnum< String >( "1D_5" ); - config.addEntryEnum< String >( "1D_6" ); - config.addEntryEnum< String >( "1D_Noh" ); - config.addEntryEnum< String >( "1D_peak" ); - config.addEntryEnum< String >( "2D_3" ); - config.addEntryEnum< String >( "2D_4" ); - config.addEntryEnum< String >( "2D_6" ); - config.addEntryEnum< String >( "2D_12" ); - config.addEntryEnum< String >( "2D_15" ); - config.addEntryEnum< String >( "2D_17" ); - } - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - String initial = parameters.getParameter< String >( prefix + "initial" ); - if(initial == prefix + "none") - { - this->discontinuityPlacement.setup( parameters, prefix + "discontinuity-placement-" ); - this->gamma = parameters.getParameter< double >( prefix + "gamma" ); -/* - this->leftVelocity.setup( parameters, prefix + "left-velocity-" ); - this->rightVelocity.setup( parameters, prefix + "right-velocity-" ); - this->leftDensity = parameters.getParameter< double >( prefix + "left-density" ); - this->rightDensity = parameters.getParameter< double >( prefix + "right-density" ); - this->leftPressure = parameters.getParameter< double >( prefix + "left-pressure" ); - this->rightPressure = parameters.getParameter< double >( prefix + "right-pressure" ); -*/ - - this->NWUDensity = parameters.getParameter< RealType >( prefix + "NWU-density" ); - this->NWUVelocity.setup( parameters, prefix + "NWU-velocity-" ); - this->NWUPressure = parameters.getParameter< RealType >( prefix + "NWU-pressure" ); - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); - this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); - this->SWUPressure = parameters.getParameter< RealType >( prefix + "SWU-pressure" ); - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); - this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); - this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); - this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); - this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); - this->SWDPressure = parameters.getParameter< RealType >( prefix + "SWD-pressure" ); - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); - this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); - this->NEUPressure = parameters.getParameter< RealType >( prefix + "NEU-pressure" ); - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); - this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); - this->SEUPressure = parameters.getParameter< RealType >( prefix + "SEU-pressure" ); - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); - this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); - this->NEDPressure = parameters.getParameter< RealType >( prefix + "NED-pressure" ); - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); - this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); - this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - - } - if(initial == prefix + "1D_2") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -2.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_3a") - predefinedInitialCondition( 1.4, 0.8, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1000.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.01, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -19.59745, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -19.59745, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_4") - predefinedInitialCondition( 1.666, 0.4, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 5.99924, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 5.99242, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 460.894, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 46.095, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 19.5975, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -6.19633, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_5") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_6") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.1, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.1, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.1, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_Noh") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.000001, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.000001, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_peak") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 0.12612, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 6.5915, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 782.929, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 3.15449, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 8.90470, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.26542, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_3") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5323, 0.138, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.5, 0.5323, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.3, 0.029, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.5, 0.3, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 1.206, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.206, 1.206, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.206, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_4") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5065, 1.1, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.1, 0.5065, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.35, 1.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.1, 0.35, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.8939, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.8939, 0.8939, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.8939, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_6") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 3.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.75, 0.5, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -0.75, 0.5, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.75, -0.5, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -0.75, -0.5, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_12") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 1.0, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.5313, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.4, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.7276, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.7276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_15") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5197, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5313, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.4, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - -0.6259, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.1, -0.3, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.1, -0.3, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.1, 0.4276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_17") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0625, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5197, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.2145, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, -0.4, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.1259, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - return true; - } - - void setDiscontinuityPlacement( const PointType& v ) - { - this->discontinuityPlacement = v; - } - - const PointType& getDiscontinuityPlasement() const - { - return this->discontinuityPlacement; - } - - void setLeftDensity( const RealType& leftDensity ) - { - this->leftDensity = leftDensity; - } - - const RealType& getLeftDensity() const - { - return this->leftDensity; - } - - void setRightDensity( const RealType& rightDensity ) - { - this->rightDensity = rightDensity; - } - - const RealType& getRightDensity() const - { - return this->rightDensity; - } - - void setLeftVelocity( const PointType& leftVelocity ) - { - this->leftVelocity = leftVelocity; - } - - const PointType& getLeftVelocity() const - { - return this->leftVelocity; - } - - void setRightVelocity( const RealType& rightVelocity ) - { - this->rightVelocity = rightVelocity; - } - - const PointType& getRightVelocity() const - { - return this->rightVelocity; - } - - void setLeftPressure( const RealType& leftPressure ) - { - this->leftPressure = leftPressure; - } - - const RealType& getLeftPressure() const - { - return this->leftPressure; - } - - void setRightPressure( const RealType& rightPressure ) - { - this->rightPressure = rightPressure; - } - - const RealType& getRightPressure() const - { - return this->rightPressure; - } - - - void predefinedInitialCondition( double preGamma, double preDiscX, double preDiscY, double preDiscZ, - double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ) - - { - this->discontinuityPlacement = PointLoad(preDiscX, preDiscY, preDiscZ); - this->gamma = preGamma; - - this->NWUDensity = preNWUDensity; - this->NWUVelocity = PointLoad(preNWUVelocityX, preNWUVelocityY, preNWUVelocityZ); - this->NWUPressure = preNWUPressure; - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = preNWUDensity; - this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); - this->SWUPressure = preSWUPressure; - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = preNWDDensity; - this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); - this->NWDPressure = preNWDPressure; - this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = preSWDDensity; - this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); - this->SWDPressure = preSWDPressure; - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = preNEUDensity; - this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); - this->NEUPressure = preNEUPressure; - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = preSEUDensity; - this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); - this->SEUPressure = preSEUPressure; - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = preNEDDensity; - this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); - this->NEDPressure = preNEDPressure; - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = preSEDDensity; - this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); - this->SEDPressure = preSEDPressure; - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - - std::cout << this->SEDEnergy; - std::cout << this->SWDEnergy; - - } - - PointType PointLoad( RealType ValueX, RealType ValueY, RealType ValueZ) - { - PointType point; - switch (Dimensions) - { - case 1: point[ 0 ] = ValueX; - break; - case 2: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - break; - case 3: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - point[ 2 ] = ValueZ; - break; - } - return point; - } - - RealType Energy( RealType Density, RealType Pressure, RealType gamma, PointType Velocity) - { - RealType energy; - switch (Dimensions) - { - case 1: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ))); - break; - case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); - break; - case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 3 ], 2 ))); - break; // druhou mocninu ps8t jako sou4in - } - return energy; - } - - void setInitialCondition( CompressibleConservativeVariables< MeshType >& conservativeVariables, - const PointType& center = PointType( 0.0 ) ) - { - RiemannProblemInitialConditionSetter* variablesSetter = new RiemannProblemInitialConditionSetter; - variablesSetter->setGamma(this->gamma); - variablesSetter->setDensity(this->NWUDensity, - this->NEUDensity, - this->SWUDensity, - this->SEUDensity, - this->NWDDensity, - this->NEDDensity, - this->SWDDensity, - this->SEDDensity); - variablesSetter->setMomentum(this->NWUMomentum, - this->NEUMomentum, - this->SWUMomentum, - this->SEUMomentum, - this->NWDMomentum, - this->NEDMomentum, - this->SWDMomentum, - this->SEDMomentum); - variablesSetter->setEnergy(this->NWUEnergy, - this->NEUEnergy, - this->SWUEnergy, - this->SEUEnergy, - this->NWDEnergy, - this->NEDEnergy, - this->SWDEnergy, - this->SEDEnergy); - variablesSetter->setDiscontinuity(this->discontinuityPlacement); - variablesSetter->placeDensity(conservativeVariables); - variablesSetter->placeMomentum(conservativeVariables); - variablesSetter->placeEnergy(conservativeVariables); - -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - -/* - typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; - typedef Operators::Analytic::Sign< Dimensions, RealType > SignType; - typedef Functions::OperatorFunction< SignType, VectorNormType > InitialConditionType; - typedef Pointers::SharedPointer< InitialConditionType, DeviceType > InitialConditionPointer; - - InitialConditionPointer initialCondition; - initialCondition->getFunction().setCenter( center ); - initialCondition->getFunction().setMaxNorm( true ); - initialCondition->getFunction().setRadius( discontinuityPlacement[ 0 ] ); - discontinuityPlacement *= 1.0 / discontinuityPlacement[ 0 ]; - for( int i = 1; i < Dimensions; i++ ) - discontinuityPlacement[ i ] = 1.0 / discontinuityPlacement[ i ]; - initialCondition->getFunction().setAnisotropy( discontinuityPlacement ); - initialCondition->getFunction().setMultiplicator( -1.0 ); - - Functions::MeshFunctionEvaluator< MeshFunctionType, InitialConditionType > evaluator; -*/ - /**** - * Density - */ -/* - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ -/* - initialCondition->getOperator().setPositiveValue( leftDensity ); - initialCondition->getOperator().setNegativeValue( rightDensity ); - evaluator.evaluate( conservativeVariables.getDensity(), initialCondition ); - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ - /**** - * Momentum - */ - -/* - for( int i = 0; i < Dimensions; i++ ) - { - initialCondition->getOperator().setPositiveValue( leftDensity * leftVelocity[ i ] ); - initialCondition->getOperator().setNegativeValue( rightDensity * rightVelocity[ i ] ); - evaluator.evaluate( conservativeVariables.getMomentum()[ i ], initialCondition ); - } -*/ - /**** - * Energy - */ -/* - conservativeVariables.getEnergy()->write( "energy-init", "gnuplot" ); -*/ -/* - const RealType leftKineticEnergy = leftVelocity.lpNorm( 2.0 ); - const RealType rightKineticEnergy = rightVelocity.lpNorm( 2.0 ); - const RealType leftEnergy = leftPressure / ( gamma - 1.0 ) + 0.5 * leftDensity * leftKineticEnergy * leftKineticEnergy; - const RealType rightEnergy = rightPressure / ( gamma - 1.0 ) + 0.5 * rightDensity * rightKineticEnergy * rightKineticEnergy; - initialCondition->getOperator().setPositiveValue( leftEnergy ); - initialCondition->getOperator().setNegativeValue( rightEnergy ); - evaluator.evaluate( (* conservativeVariables.getEnergy()), initialCondition ); - (* conservativeVariables.getEnergy())->write( "energy-init", "gnuplot" ); -*/ - } - - - protected: - - PointType discontinuityPlacement; - PointType NWUVelocity, NEUVelocity, SWUVelocity, SEUVelocity, NWDVelocity, NEDVelocity, SWDVelocity, SEDVelocity; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUPressure, NEUPressure, SWUPressure, SEUPressure, NWDPressure, NEDPressure, SWDPressure, SEDPressure; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType leftDensity, rightDensity; - PointType leftVelocity, rightVelocity; - RealType leftPressure, rightPressure; - - RealType gamma; // gamma in the ideal gas state equation -}; - -} //namespace TNL diff --git a/src/Examples/flow-sw/Upwind.h b/src/Examples/flow-sw/Upwind.h deleted file mode 100644 index 5aee91b62..000000000 --- a/src/Examples/flow-sw/Upwind.h +++ /dev/null @@ -1,158 +0,0 @@ -/*************************************************************************** - Upwind.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "UpwindContinuity.h" -#include "UpwindEnergy.h" -#include "UpwindMomentumX.h" -#include "UpwindMomentumY.h" -#include "UpwindMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class Upwind -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef UpwindContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef UpwindMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef UpwindMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef UpwindMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef UpwindEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); - } - - Upwind() - :dynamicalViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); - this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setGamma( const RealType& gamma ) - { - this->continuityOperatorPointer->setGamma( gamma ); - this->momentumXOperatorPointer->setGamma( gamma ); - this->momentumYOperatorPointer->setGamma( gamma ); - this->momentumZOperatorPointer->setGamma( gamma ); - this->energyOperatorPointer->setGamma( gamma ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->continuityOperatorPointer->setPressure( pressure ); - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setDensity( const MeshFunctionPointer& density ) - { - this->momentumXOperatorPointer->setDensity( density ); - this->momentumYOperatorPointer->setDensity( density ); - this->momentumZOperatorPointer->setDensity( density ); - this->energyOperatorPointer->setDensity( density ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType dynamicalViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flow-sw/UpwindContinuity.h b/src/Examples/flow-sw/UpwindContinuity.h deleted file mode 100644 index fc599d3d9..000000000 --- a/src/Examples/flow-sw/UpwindContinuity.h +++ /dev/null @@ -1,383 +0,0 @@ -/*************************************************************************** - UpwindContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - static String getType() - { - return String( "UpwindContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - __cuda_callable__ - RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); - else - return density * velocity; - }; - - __cuda_callable__ - RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); - else - return 0.0; - }; - - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) - - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) - - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) - + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) - ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/flow-sw/UpwindMomentumX.h b/src/Examples/flow-sw/UpwindMomentumX.h deleted file mode 100644 index edd375620..000000000 --- a/src/Examples/flow-sw/UpwindMomentumX.h +++ /dev/null @@ -1,433 +0,0 @@ -/*************************************************************************** - UpwindMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) - ) -// 1D T_11_x - - 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ) -// 2D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_21_y - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south - ) * hxInverse * hyInverse - ) * this->dynamicalViscosity; - - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) - ) -// 3D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_21_x - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// T_31_x - + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-sw/UpwindMomentumY.h b/src/Examples/flow-sw/UpwindMomentumY.h deleted file mode 100644 index 4b5a7bcb2..000000000 --- a/src/Examples/flow-sw/UpwindMomentumY.h +++ /dev/null @@ -1,403 +0,0 @@ -/*************************************************************************** - UpwindMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ) -// 2D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_12_x - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east - ) * hxSquareInverse - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) - ) -// T_12_y - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_32_y - + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-sw/UpwindMomentumZ.h b/src/Examples/flow-sw/UpwindMomentumZ.h deleted file mode 100644 index 887eec977..000000000 --- a/src/Examples/flow-sw/UpwindMomentumZ.h +++ /dev/null @@ -1,338 +0,0 @@ -/*************************************************************************** - UpwindMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) - - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) - ) -// T_13_z - + ( ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - + ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - ) - * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity; - } - - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-sw/navierStokes.cpp b/src/Examples/flow-sw/navierStokes.cpp deleted file mode 100644 index 7dffcb059..000000000 --- a/src/Examples/flow-sw/navierStokes.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "navierStokes.h" diff --git a/src/Examples/flow-sw/navierStokes.cu b/src/Examples/flow-sw/navierStokes.cu deleted file mode 100644 index 7dffcb059..000000000 --- a/src/Examples/flow-sw/navierStokes.cu +++ /dev/null @@ -1 +0,0 @@ -#include "navierStokes.h" diff --git a/src/Examples/flow-sw/navierStokes.h b/src/Examples/flow-sw/navierStokes.h deleted file mode 100644 index 0d37ad41c..000000000 --- a/src/Examples/flow-sw/navierStokes.h +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include -#include -#include -#include -#include "navierStokesProblem.h" -#include "Upwind.h" -#include "navierStokesRhs.h" -#include "navierStokesBuildConfigTag.h" - -#include "RiemannProblemInitialCondition.h" -#include "BoundaryConditionsCavity.h" -#include "BoundaryConditionsBoiler.h" - -using namespace TNL; - -typedef navierStokesBuildConfigTag BuildConfig; - -/**** - * Uncomment the following (and comment the previous line) for the complete build. - * This will include support for all floating point precisions, all indexing types - * and more solvers. You may then choose between them from the command line. - * The compile time may, however, take tens of minutes or even several hours, - * especially if CUDA is enabled. Use this, if you want, only for the final build, - * not in the development phase. - */ -//typedef tnlDefaultConfigTag BuildConfig; - -template< typename ConfigTag >class navierStokesConfig -{ - public: - static void configSetup( Config::ConfigDescription & config ) - { - config.addDelimiter( "Inviscid flow settings:" ); - config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); - config.addEntryEnum< String >( "boiler" ); - config.addEntryEnum< String >( "cavity" ); - config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); - config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); - config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); - config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); - typedef Meshes::Grid< 3 > Mesh; - Upwind< Mesh >::configSetup( config, "inviscid-operators-" ); - RiemannProblemInitialCondition< Mesh >::configSetup( config ); - - /**** - * Add definition of your solver command line arguments. - */ - - } -}; - -template< typename Real, - typename Device, - typename Index, - typename MeshType, - typename ConfigTag, - typename SolverStarter, - typename Communicator > -class navierStokesSetter -{ - public: - - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - static bool run( const Config::ParameterContainer & parameters ) - { - enum { Dimension = MeshType::getMeshDimension() }; - typedef Upwind< MeshType, Real, Index > ApproximateOperator; - typedef navierStokesRhs< MeshType, Real > RightHandSide; - typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; - - /**** - * Resolve the template arguments of your solver here. - * The following code is for the Dirichlet and the Neumann boundary conditions. - * Both can be constant or defined as descrete values of Vector. - */ - typedef Functions::Analytic::Constant< Dimension, Real > Constant; - String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); - if( boundaryConditionsType == "cavity" ) - { - typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; - typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "boiler" ) - { - typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; - typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - - return true;} - -}; - -int main( int argc, char* argv[] ) -{ - Solvers::Solver< navierStokesSetter, navierStokesConfig, BuildConfig > solver; - if( ! solver. run( argc, argv ) ) - return EXIT_FAILURE; - return EXIT_SUCCESS; -} diff --git a/src/Examples/flow-sw/navierStokesBuildConfigTag.h b/src/Examples/flow-sw/navierStokesBuildConfigTag.h deleted file mode 100644 index 78e8c57c3..000000000 --- a/src/Examples/flow-sw/navierStokesBuildConfigTag.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef navierStokesBUILDCONFIGTAG_H_ -#define navierStokesBUILDCONFIGTAG_H_ - -#include - -namespace TNL { - -class navierStokesBuildConfigTag{}; - -namespace Solvers { - -/**** - * Turn off support for float and long double. - */ -template<> struct ConfigTagReal< navierStokesBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct ConfigTagReal< navierStokesBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct ConfigTagIndex< navierStokesBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct ConfigTagIndex< navierStokesBuildConfigTag, long int >{ enum { enabled = false }; }; - -//template< int Dimension > struct ConfigTagDimension< navierStokesBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; - -/**** - * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. - */ -/* -template< int Dimension, typename Real, typename Device, typename Index > - struct ConfigTagMesh< navierStokesBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > - { enum { enabled = ConfigTagDimension< navierStokesBuildConfigTag, Dimension >::enabled && - ConfigTagReal< navierStokesBuildConfigTag, Real >::enabled && - ConfigTagDevice< navierStokesBuildConfigTag, Device >::enabled && - ConfigTagIndex< navierStokesBuildConfigTag, Index >::enabled }; }; -*/ - -/**** - * Please, chose your preferred time discretisation here. - */ -template<> struct ConfigTagTimeDiscretisation< navierStokesBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; -template<> struct ConfigTagTimeDiscretisation< navierStokesBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; -template<> struct ConfigTagTimeDiscretisation< navierStokesBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; - -/**** - * Only the Runge-Kutta-Merson solver is enabled by default. - */ -template<> struct ConfigTagExplicitSolver< navierStokesBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; - -} // namespace Solvers - -namespace Meshes { -namespace BuildConfigTags { - -template< int Dimensions > struct GridDimensionTag< navierStokesBuildConfigTag, Dimensions >{ enum { enabled = ( Dimensions == 1 ) }; }; - -/**** - * Turn off support for float and long double. - */ -template<> struct GridRealTag< navierStokesBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct GridRealTag< navierStokesBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct GridIndexTag< navierStokesBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct GridIndexTag< navierStokesBuildConfigTag, long int >{ enum { enabled = false }; }; - -} // namespace BuildConfigTags -} // namespace Meshes - -} // namespace TNL - -#endif /* navierStokesBUILDCONFIGTAG_H_ */ diff --git a/src/Examples/flow-sw/navierStokesProblem_impl.h b/src/Examples/flow-sw/navierStokesProblem_impl.h deleted file mode 100644 index 886c9f03f..000000000 --- a/src/Examples/flow-sw/navierStokesProblem_impl.h +++ /dev/null @@ -1,458 +0,0 @@ -/*************************************************************************** - navierStokesProblem_impl.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -#include "RiemannProblemInitialCondition.h" -#include "CompressibleConservativeVariables.h" -#include "PhysicalVariablesGetter.h" -#include "navierStokesProblem.h" - -#include "UpwindContinuity.h" -#include "UpwindEnergy.h" -#include "UpwindMomentumX.h" -#include "UpwindMomentumY.h" -#include "UpwindMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -String -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getTypeStatic() -{ - return String( "navierStokesProblem< " ) + Mesh :: getTypeStatic() + " >"; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -String -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getPrologHeader() const -{ - return String( "Inviscid flow solver" ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const -{ - /**** - * Add data you want to have in the computation report (log) as follows: - * logger.writeParameter< double >( "Parameter description", parameter ); - */ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setup( const Config::ParameterContainer& parameters, - const String& prefix ) -{ - if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || - ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || - ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) - return false; - this->gamma = parameters.getParameter< double >( "gamma" ); - velocity->setMesh( this->getMesh() ); - pressure->setMesh( this->getMesh() ); - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -typename navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >::IndexType -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getDofs() const -{ - /**** - * Return number of DOFs (degrees of freedom) i.e. number - * of unknowns to be resolved by the main solver. - */ - return this->conservativeVariables->getDofs( this->getMesh() ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -bindDofs( DofVectorPointer& dofVector ) -{ - this->conservativeVariables->bind( this->getMesh(), dofVector ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ) -{ - CompressibleConservativeVariables< MeshType > conservativeVariables; - conservativeVariables.bind( this->getMesh(), dofs ); - const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); - this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); - this->speedIncrement = parameters.getParameter< RealType >( "speed-increment" ); - this->cavitySpeed = parameters.getParameter< RealType >( "cavity-speed" ); - if( initialConditionType == "riemann-problem" ) - { - RiemannProblemInitialCondition< MeshType > initialCondition; - if( ! initialCondition.setup( parameters ) ) - return false; - initialCondition.setInitialCondition( conservativeVariables ); - return true; - } - std::cerr << "Unknown initial condition " << initialConditionType << std::endl; - return false; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > - template< typename Matrix > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setupLinearSystem( Matrix& matrix ) -{ -/* const IndexType dofs = this->getDofs( mesh ); - typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; - CompressedRowLengthsVectorType rowLengths; - if( ! rowLengths.setSize( dofs ) ) - return false; - MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; - matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, - differentialOperator, - boundaryCondition, - rowLengths ); - matrix.setDimensions( dofs, dofs ); - if( ! matrix.setCompressedRowLengths( rowLengths ) ) - return false;*/ - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ) -{ - std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; - - this->bindDofs( dofs ); - PhysicalVariablesGetter< MeshType > physicalVariablesGetter; - physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - FileName fileName; - fileName.setExtension( "tnl" ); - fileName.setIndex( step ); - fileName.setFileNameBase( "density-" ); - this->conservativeVariables->getDensity()->save( fileName.getFileName() ); - - fileName.setFileNameBase( "velocity-" ); - this->velocity->save( fileName.getFileName() ); - - fileName.setFileNameBase( "pressure-" ); - this->pressure->save( fileName.getFileName() ); - - /*fileName.setFileNameBase( "energy-" ); - if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) - return false; - - fileName.setFileNameBase( "momentum-" ); - if( ! this->conservativeVariables->getMomentum()->save( fileName.getFileName() ) ) - return false;*/ - - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ) -{ - typedef typename MeshType::Cell Cell; - const MeshPointer& mesh = this->getMesh(); - - /**** - * Bind DOFs - */ - this->conservativeVariables->bind( mesh, _u ); - this->conservativeVariablesRHS->bind( mesh, _fu ); - this->velocity->setMesh( mesh ); - this->pressure->setMesh( mesh ); - -// this->pressure->write( "pressure1", "gnuplot" ); -// getchar(); - /**** - * Resolve the physical variables - */ - PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; - physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - /**** - * Set-up operators - */ - typedef typename InviscidOperators::ContinuityOperatorType ContinuityOperatorType; - typedef typename InviscidOperators::MomentumXOperatorType MomentumXOperatorType; - typedef typename InviscidOperators::MomentumYOperatorType MomentumYOperatorType; - typedef typename InviscidOperators::MomentumZOperatorType MomentumZOperatorType; - typedef typename InviscidOperators::EnergyOperatorType EnergyOperatorType; - - this->inviscidOperatorsPointer->setTau( tau ); - this->inviscidOperatorsPointer->setVelocity( this->velocity ); - this->inviscidOperatorsPointer->setPressure( this->pressure ); - this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); - this->inviscidOperatorsPointer->setGamma( this->gamma ); - - /**** - * Set Up Boundary Conditions - */ - - typedef typename BoundaryCondition::DensityBoundaryConditionsType DensityBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumXBoundaryConditionsType MomentumXBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumYBoundaryConditionsType MomentumYBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumZBoundaryConditionsType MomentumZBoundaryConditionsType; - typedef typename BoundaryCondition::EnergyBoundaryConditionsType EnergyBoundaryConditionsType; - - /**** - * Update Boundary Conditions - */ - if(this->speedIncrementUntil > time ) - { - this->boundaryConditionPointer->setTimestep(this->speedIncrement); - } - else - { - this->boundaryConditionPointer->setTimestep(0); - } - this->boundaryConditionPointer->setSpeed(this->cavitySpeed); - this->boundaryConditionPointer->setCompressibleConservativeVariables(this->conservativeVariables); - this->boundaryConditionPointer->setGamma(this->gamma); - this->boundaryConditionPointer->setPressure(this->pressure); - - - /**** - * Continuity equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, ContinuityOperatorType, DensityBoundaryConditionsType, RightHandSide > explicitUpdaterContinuity; - explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); - explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer->getDensityBoundaryCondition() ); - explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterContinuity.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - this->conservativeVariables->getDensity(), - this->conservativeVariablesRHS->getDensity() ); - - /**** - * Momentum equations - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumXOperatorType, MomentumXBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumX; - explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); - explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer->getMomentumXBoundaryCondition() ); - explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumX.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); - - if( Dimensions > 1 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumYOperatorType, MomentumYBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumY; - explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); - explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer->getMomentumYBoundaryCondition() ); - explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumY.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); - } - - if( Dimensions > 2 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, MomentumZBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumZ; - explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); - explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer->getMomentumZBoundaryCondition() ); - explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumZ.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); - } - - - /**** - * Energy equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, EnergyOperatorType, EnergyBoundaryConditionsType, RightHandSide > explicitUpdaterEnergy; - explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); - explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer->getEnergyBoundaryCondition() ); - explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterEnergy.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - this->conservativeVariablesRHS->getEnergy(), // uRhoVelocityX, - this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); - -/* this->pressure->write( "pressure3", "gnuplot" ); - getchar(); - this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); - this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); - this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); - getchar();*/ - -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > - template< typename Matrix > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - Matrix& matrix, - DofVectorPointer& b ) -{ -/* LinearSystemAssembler< Mesh, - MeshFunctionType, - InviscidOperators, - BoundaryCondition, - RightHandSide, - BackwardTimeDiscretisation, - Matrix, - DofVectorType > systemAssembler; - - MeshFunction< Mesh > u( mesh, _u ); - systemAssembler.template assembly< typename Mesh::Cell >( time, - tau, - mesh, - this->differentialOperator, - this->boundaryCondition, - this->rightHandSide, - u, - matrix, - b );*/ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ) -{ - /* - typedef typename MeshType::Cell Cell; - int count = mesh->template getEntitiesCount< Cell >()/4; - //bind _u - this->_uRho.bind( *dofs, 0, count); - this->_uRhoVelocityX.bind( *dofs, count, count); - this->_uRhoVelocityY.bind( *dofs, 2 * count, count); - this->_uEnergy.bind( *dofs, 3 * count, count); - - MeshFunctionType velocity( mesh, this->velocity ); - MeshFunctionType velocityX( mesh, this->velocityX ); - MeshFunctionType velocityY( mesh, this->velocityY ); - MeshFunctionType pressure( mesh, this->pressure ); - MeshFunctionType uRho( mesh, _uRho ); - MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); - MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); - MeshFunctionType uEnergy( mesh, _uEnergy ); - //Generating differential operators - Velocity navierStokes2DVelocity; - VelocityX navierStokes2DVelocityX; - VelocityY navierStokes2DVelocityY; - Pressure navierStokes2DPressure; - - //velocityX - navierStokes2DVelocityX.setRhoVelX(uRhoVelocityX); - navierStokes2DVelocityX.setRho(uRho); -// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; -// velocityX = OFVelocityX; - - //velocityY - navierStokes2DVelocityY.setRhoVelY(uRhoVelocityY); - navierStokes2DVelocityY.setRho(uRho); -// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; -// velocityY = OFVelocityY; - - //velocity - navierStokes2DVelocity.setVelX(velocityX); - navierStokes2DVelocity.setVelY(velocityY); -// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; -// velocity = OFVelocity; - - //pressure - navierStokes2DPressure.setGamma(gamma); - navierStokes2DPressure.setVelocity(velocity); - navierStokes2DPressure.setEnergy(uEnergy); - navierStokes2DPressure.setRho(uRho); -// OperatorFunction< navierStokes2DPressure, MeshFunction, void, time > OFPressure; -// pressure = OFPressure; - */ - return true; -} - -} // namespace TNL - diff --git a/src/Examples/flow-sw/navierStokesRhs.h b/src/Examples/flow-sw/navierStokesRhs.h deleted file mode 100644 index 3c82ad453..000000000 --- a/src/Examples/flow-sw/navierStokesRhs.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef navierStokesRHS_H_ -#define navierStokesRHS_H_ - -#include - -namespace TNL { - -template< typename Mesh, typename Real >class navierStokesRhs - : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > - { - public: - - typedef Mesh MeshType; - typedef Real RealType; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; - } - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const Real& time = 0.0 ) const - { - typedef typename MeshEntity::MeshType::PointType PointType; - PointType v = entity.getCenter(); - return 0.0; - } -}; - -} //namespace TNL - -#endif /* navierStokesRHS_H_ */ diff --git a/src/Examples/flow-sw/run-navier-stokes-sw b/src/Examples/flow-sw/run-navier-stokes-sw deleted file mode 100644 index 9ebf9cbb5..000000000 --- a/src/Examples/flow-sw/run-navier-stokes-sw +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 2 \ - --origin-x 0.0 \ - --origin-y 0.0 \ - --proportions-x 1.0 \ - --proportions-y 1.0 \ - --size-x 100 \ - --size-y 100 - -tnl-init --test-function sin-wave \ - --output-file init.tnl -tnl-euler-2d --initial-condition riemann-problem \ - --discontinuity-placement-0 0.3 \ - --discontinuity-placement-1 0.3 \ - --discontinuity-placement-2 0.3 \ - --time-discretisation explicit \ - --boundary-conditions-type neumann \ - --boundary-conditions-constant 0 \ - --discrete-solver euler \ - --time-step 0.0001 \ - --snapshot-period 0.01 \ - --final-time 1.0 - -tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/flow-vl/BoundaryConditionsBoiler.h b/src/Examples/flow-vl/BoundaryConditionsBoiler.h deleted file mode 100644 index f61f988da..000000000 --- a/src/Examples/flow-vl/BoundaryConditionsBoiler.h +++ /dev/null @@ -1,137 +0,0 @@ -#include - -#include "DensityBoundaryConditionBoiler.h" -#include "MomentumXBoundaryConditionBoiler.h" -#include "MomentumYBoundaryConditionBoiler.h" -#include "MomentumZBoundaryConditionBoiler.h" -#include "EnergyBoundaryConditionBoiler.h" - -namespace TNL { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class BoundaryConditionsBoiler -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef Index IndexType; - typedef Function FunctionType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef typename Mesh::DeviceType DeviceType; - - typedef TNL::Operators::DensityBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; - typedef TNL::Operators::MomentumXBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; - typedef TNL::Operators::MomentumYBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; - typedef TNL::Operators::MomentumZBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; - typedef TNL::Operators::EnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - - typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - return true; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - } - - void setTimestep(const RealType timestep) - { - this->densityBoundaryConditionsPointer->setTimestep(timestep); - this->momentumXBoundaryConditionsPointer->setTimestep(timestep); - this->momentumYBoundaryConditionsPointer->setTimestep(timestep); - this->momentumZBoundaryConditionsPointer->setTimestep(timestep); - this->energyBoundaryConditionsPointer->setTimestep(timestep); - } - - void setGamma(const RealType gamma) - { - this->densityBoundaryConditionsPointer->setGamma(gamma); - this->momentumXBoundaryConditionsPointer->setGamma(gamma); - this->momentumYBoundaryConditionsPointer->setGamma(gamma); - this->momentumZBoundaryConditionsPointer->setGamma(gamma); - this->energyBoundaryConditionsPointer->setGamma(gamma); - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->densityBoundaryConditionsPointer->setPressure(pressure); - this->momentumXBoundaryConditionsPointer->setPressure(pressure); - this->momentumYBoundaryConditionsPointer->setPressure(pressure); - this->momentumZBoundaryConditionsPointer->setPressure(pressure); - this->energyBoundaryConditionsPointer->setPressure(pressure); - } - - void setSpeed(const RealType cavitySpeed) - { - this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - } - - DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() - { - return this->densityBoundaryConditionsPointer; - } - - MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() - { - return this->momentumXBoundaryConditionsPointer; - } - - MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() - { - return this->momentumYBoundaryConditionsPointer; - } - - MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() - { - return this->momentumZBoundaryConditionsPointer; - } - - EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() - { - return this->energyBoundaryConditionsPointer; - } - - - protected: - DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; - MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; - MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; - MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; - EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; - -}; - -} //namespace TNL diff --git a/src/Examples/flow-vl/BoundaryConditionsCavity.h b/src/Examples/flow-vl/BoundaryConditionsCavity.h deleted file mode 100644 index bbae2d3e9..000000000 --- a/src/Examples/flow-vl/BoundaryConditionsCavity.h +++ /dev/null @@ -1,137 +0,0 @@ -#include - -#include "DensityBoundaryConditionCavity.h" -#include "MomentumXBoundaryConditionCavity.h" -#include "MomentumYBoundaryConditionCavity.h" -#include "MomentumZBoundaryConditionCavity.h" -#include "EnergyBoundaryConditionCavity.h" - -namespace TNL { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class BoundaryConditionsCavity -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef Index IndexType; - typedef Function FunctionType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef typename Mesh::DeviceType DeviceType; - - typedef TNL::Operators::DensityBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; - typedef TNL::Operators::MomentumXBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; - typedef TNL::Operators::MomentumYBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; - typedef TNL::Operators::MomentumZBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; - typedef TNL::Operators::EnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - - typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - return true; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - } - - void setTimestep(const RealType timestep) - { - this->densityBoundaryConditionsPointer->setTimestep(timestep); - this->momentumXBoundaryConditionsPointer->setTimestep(timestep); - this->momentumYBoundaryConditionsPointer->setTimestep(timestep); - this->momentumZBoundaryConditionsPointer->setTimestep(timestep); - this->energyBoundaryConditionsPointer->setTimestep(timestep); - } - - void setGamma(const RealType gamma) - { - this->densityBoundaryConditionsPointer->setGamma(gamma); - this->momentumXBoundaryConditionsPointer->setGamma(gamma); - this->momentumYBoundaryConditionsPointer->setGamma(gamma); - this->momentumZBoundaryConditionsPointer->setGamma(gamma); - this->energyBoundaryConditionsPointer->setGamma(gamma); - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->densityBoundaryConditionsPointer->setPressure(pressure); - this->momentumXBoundaryConditionsPointer->setPressure(pressure); - this->momentumYBoundaryConditionsPointer->setPressure(pressure); - this->momentumZBoundaryConditionsPointer->setPressure(pressure); - this->energyBoundaryConditionsPointer->setPressure(pressure); - } - - void setSpeed(const RealType cavitySpeed) - { - this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - } - - DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() - { - return this->densityBoundaryConditionsPointer; - } - - MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() - { - return this->momentumXBoundaryConditionsPointer; - } - - MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() - { - return this->momentumYBoundaryConditionsPointer; - } - - MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() - { - return this->momentumZBoundaryConditionsPointer; - } - - EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() - { - return this->energyBoundaryConditionsPointer; - } - - - protected: - DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; - MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; - MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; - MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; - EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; - -}; - -} //namespace TNL diff --git a/src/Examples/flow-vl/CMakeLists.txt b/src/Examples/flow-vl/CMakeLists.txt deleted file mode 100644 index 47bb72276..000000000 --- a/src/Examples/flow-vl/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -set( tnl_flow_vl_HEADERS - CompressibleConservativeVariables.h ) - -set( tnl_flow_vl_SOURCES - navierStokes.cpp - navierStokes.cu ) - -IF( BUILD_CUDA ) - CUDA_ADD_EXECUTABLE(tnl-navier-stokes-vl navierStokes.cu) -ELSE( BUILD_CUDA ) - ADD_EXECUTABLE(tnl-navier-stokes-vl navierStokes.cpp) -ENDIF( BUILD_CUDA ) - - -INSTALL( TARGETS tnl-navier-stokes-vl - RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) - -INSTALL( FILES run-navier-stokes-vl - ${tnl_inviscid_flow_SOURCES} - DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/navier-stokes-vl ) diff --git a/src/Examples/flow-vl/CompressibleConservativeVariables.h b/src/Examples/flow-vl/CompressibleConservativeVariables.h deleted file mode 100644 index 01e820686..000000000 --- a/src/Examples/flow-vl/CompressibleConservativeVariables.h +++ /dev/null @@ -1,147 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -namespace TNL { - -template< typename Mesh > -class CompressibleConservativeVariables -{ - public: - typedef Mesh MeshType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; - - CompressibleConservativeVariables(){}; - - CompressibleConservativeVariables( const MeshPointer& meshPointer ) - : density( meshPointer ), - momentum( meshPointer ), - //pressure( meshPointer ), - energy( meshPointer ){}; - - void setMesh( const MeshPointer& meshPointer ) - { - this->density->setMesh( meshPointer ); - this->momentum->setMesh( meshPointer ); - //this->pressure.setMesh( meshPointer ); - this->energy->setMesh( meshPointer ); - } - - template< typename Vector > - void bind( const MeshPointer& meshPointer, - const Vector& data, - IndexType offset = 0 ) - { - IndexType currentOffset( offset ); - this->density->bind( meshPointer, data, currentOffset ); - currentOffset += this->density->getDofs( meshPointer ); - for( IndexType i = 0; i < Dimensions; i++ ) - { - ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); - currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); - } - this->energy->bind( meshPointer, data, currentOffset ); - } - - IndexType getDofs( const MeshPointer& meshPointer ) const - { - return this->density->getDofs( meshPointer ) + - this->momentum->getDofs( meshPointer ) + - this->energy->getDofs( meshPointer ); - } - - MeshFunctionPointer& getDensity() - { - return this->density; - } - - const MeshFunctionPointer& getDensity() const - { - return this->density; - } - - void setDensity( MeshFunctionPointer& density ) - { - this->density = density; - } - - MomentumFieldPointer& getMomentum() - { - return this->momentum; - } - - const MomentumFieldPointer& getMomentum() const - { - return this->momentum; - } - - void setMomentum( MomentumFieldPointer& momentum ) - { - this->momentum = momentum; - } - - /*MeshFunctionPointer& getPressure() - { - return this->pressure; - } - - const MeshFunctionPointer& getPressure() const - { - return this->pressure; - } - - void setPressure( MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }*/ - - MeshFunctionPointer& getEnergy() - { - return this->energy; - } - - const MeshFunctionPointer& getEnergy() const - { - return this->energy; - } - - void setEnergy( MeshFunctionPointer& energy ) - { - this->energy = energy; - } - - void getVelocityField( VelocityFieldType& velocityField ) - { - - } - - protected: - - MeshFunctionPointer density; - MomentumFieldPointer momentum; - MeshFunctionPointer energy; - -}; - -} // namespace TN diff --git a/src/Examples/flow-vl/DensityBoundaryConditionBoiler.h b/src/Examples/flow-vl/DensityBoundaryConditionBoiler.h deleted file mode 100644 index 6231f6780..000000000 --- a/src/Examples/flow-vl/DensityBoundaryConditionBoiler.h +++ /dev/null @@ -1,542 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class DensityBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class DensityBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return u[ neighborEntities.template getEntityIndex< 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if (entity.getCoordinates().y() < 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if (entity.getCoordinates().z() < 0.8 * ( entity.getMesh().getDimensions().z() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionBoilers: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-vl/EnergyBoundaryConditionBoiler.h b/src/Examples/flow-vl/EnergyBoundaryConditionBoiler.h deleted file mode 100644 index a99fdf015..000000000 --- a/src/Examples/flow-vl/EnergyBoundaryConditionBoiler.h +++ /dev/null @@ -1,854 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class EnergyBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function> -class EnergyBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed - * - this->cavitySpeed - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - * - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - );*/ - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - * - this->cavitySpeed * ( -1 ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - ); - else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - );*/ - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - + - this->cavitySpeed - * - this->cavitySpeed - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - );*/ - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - + 0 - ) - );*/ - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - * - this->cavitySpeed - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - * - this->cavitySpeed * ( -1 ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - * - this->cavitySpeed - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - * - this->cavitySpeed * ( -1 ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) -{ - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * - ( - ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( - this->cavitySpeed - * - this->cavitySpeed - ) - ); - - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-vl/LaxFridrichs.h b/src/Examples/flow-vl/LaxFridrichs.h deleted file mode 100644 index c56d20aed..000000000 --- a/src/Examples/flow-vl/LaxFridrichs.h +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - LaxFridrichs.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichs -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef LaxFridrichsContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); - } - - LaxFridrichs() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); - this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); - - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flow-vl/LaxFridrichsContinuity.h b/src/Examples/flow-vl/LaxFridrichsContinuity.h deleted file mode 100644 index 82747cd18..000000000 --- a/src/Examples/flow-vl/LaxFridrichsContinuity.h +++ /dev/null @@ -1,288 +0,0 @@ -/*************************************************************************** - LaxFridrichsContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsContinuityBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - RealType artificialViscosity; -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) - - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse - + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/flow-vl/LaxFridrichsEnergy.h b/src/Examples/flow-vl/LaxFridrichsEnergy.h deleted file mode 100644 index 03019ed23..000000000 --- a/src/Examples/flow-vl/LaxFridrichsEnergy.h +++ /dev/null @@ -1,309 +0,0 @@ -/*************************************************************************** - LaxFridrichsEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east - - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse; - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse - + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) - -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/flow-vl/LaxFridrichsMomentumBase.h b/src/Examples/flow-vl/LaxFridrichsMomentumBase.h deleted file mode 100644 index cc2561748..000000000 --- a/src/Examples/flow-vl/LaxFridrichsMomentumBase.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsMomentumBase() - : artificialViscosity( 1.0 ){}; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flow-vl/LaxFridrichsMomentumX.h b/src/Examples/flow-vl/LaxFridrichsMomentumX.h deleted file mode 100644 index 63def12d3..000000000 --- a/src/Examples/flow-vl/LaxFridrichsMomentumX.h +++ /dev/null @@ -1,276 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - //const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - //const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - //const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - //const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_u[ up ] * velocity_z_up ) - - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-vl/LaxFridrichsMomentumY.h b/src/Examples/flow-vl/LaxFridrichsMomentumY.h deleted file mode 100644 index 8ce42282d..000000000 --- a/src/Examples/flow-vl/LaxFridrichsMomentumY.h +++ /dev/null @@ -1,260 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse - + ( ( rho_v[ up ] * velocity_z_up ) - - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-vl/LaxFridrichsMomentumZ.h b/src/Examples/flow-vl/LaxFridrichsMomentumZ.h deleted file mode 100644 index a67e862ce..000000000 --- a/src/Examples/flow-vl/LaxFridrichsMomentumZ.h +++ /dev/null @@ -1,240 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) - -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) - - ( rho_w[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_w[ north ] * velocity_y_north ) - - ( rho_w[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) - - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-vl/MomentumXBoundaryConditionBoiler.h b/src/Examples/flow-vl/MomentumXBoundaryConditionBoiler.h deleted file mode 100644 index dfe63e076..000000000 --- a/src/Examples/flow-vl/MomentumXBoundaryConditionBoiler.h +++ /dev/null @@ -1,594 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumXBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumXBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - ); - else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - );*/ - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - );*/ - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - ); - else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-vl/MomentumXBoundaryConditionCavity.h b/src/Examples/flow-vl/MomentumXBoundaryConditionCavity.h deleted file mode 100644 index 07abfdbeb..000000000 --- a/src/Examples/flow-vl/MomentumXBoundaryConditionCavity.h +++ /dev/null @@ -1,570 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumXBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumXBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - );*/ - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - * ( - ( this->cavitySpeed/* - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 )*/ - ) - ); - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-vl/MomentumYBoundaryConditionBoiler.h b/src/Examples/flow-vl/MomentumYBoundaryConditionBoiler.h deleted file mode 100644 index 83b6282dd..000000000 --- a/src/Examples/flow-vl/MomentumYBoundaryConditionBoiler.h +++ /dev/null @@ -1,588 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumYBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumYBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - );*/ - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - );*/ - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-vl/MomentumYBoundaryConditionCavity.h b/src/Examples/flow-vl/MomentumYBoundaryConditionCavity.h deleted file mode 100644 index a83dd653f..000000000 --- a/src/Examples/flow-vl/MomentumYBoundaryConditionCavity.h +++ /dev/null @@ -1,564 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumYBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumYBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - );*/ - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - );*/ - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-vl/MomentumZBoundaryConditionBoiler.h b/src/Examples/flow-vl/MomentumZBoundaryConditionBoiler.h deleted file mode 100644 index 9d887857c..000000000 --- a/src/Examples/flow-vl/MomentumZBoundaryConditionBoiler.h +++ /dev/null @@ -1,563 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumZBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumZBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-vl/MomentumZBoundaryConditionCavity.h b/src/Examples/flow-vl/MomentumZBoundaryConditionCavity.h deleted file mode 100644 index 5fe6f22e5..000000000 --- a/src/Examples/flow-vl/MomentumZBoundaryConditionCavity.h +++ /dev/null @@ -1,554 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumZBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumZBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-vl/PhysicalVariablesGetter.h b/src/Examples/flow-vl/PhysicalVariablesGetter.h deleted file mode 100644 index d7eeb7618..000000000 --- a/src/Examples/flow-vl/PhysicalVariablesGetter.h +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { - -template< typename Mesh > -class PhysicalVariablesGetter -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - VelocityGetter( MeshFunctionPointer density, - MeshFunctionPointer momentum ) - : density( density ), momentum( momentum ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) - return 0; - else - return momentum.template getData< DeviceType >()( meshEntity ) / - density.template getData< DeviceType >()( meshEntity ); - } - - protected: - const MeshFunctionPointer density, momentum; - }; - - class PressureGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - PressureGetter( MeshFunctionPointer density, - MeshFunctionPointer energy, - VelocityFieldPointer momentum, - const RealType& gamma ) - : density( density ), energy( energy ), momentum( momentum ), gamma( gamma ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - const RealType e = energy.template getData< DeviceType >()( meshEntity ); - const RealType rho = density.template getData< DeviceType >()( meshEntity ); - const RealType momentumNorm = lpNorm( momentum.template getData< DeviceType >().getVector( meshEntity ), 2.0 ); - if( rho == 0.0 ) - return 0; - else - return ( gamma - 1.0 ) * ( e - 0.5 * momentumNorm * momentumNorm / rho ); - } - - protected: - const MeshFunctionPointer density, energy; - const VelocityFieldPointer momentum; - const RealType gamma; - }; - - - void getVelocity( const ConservativeVariablesPointer& conservativeVariables, - VelocityFieldPointer& velocity ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; - for( int i = 0; i < Dimensions; i++ ) - { - Pointers::SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), - ( *conservativeVariables->getMomentum() )[ i ] ); - evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); - } - } - - void getPressure( const ConservativeVariablesPointer& conservativeVariables, - const RealType& gamma, - MeshFunctionPointer& pressure ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; - Pointers::SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), - conservativeVariables->getEnergy(), - conservativeVariables->getMomentum(), - gamma ); - evaluator.evaluate( pressure, pressureGetter ); - } - -}; - -} //namespace TNL diff --git a/src/Examples/flow-vl/UpwindContinuity.h b/src/Examples/flow-vl/UpwindContinuity.h deleted file mode 100644 index 20bae4fbb..000000000 --- a/src/Examples/flow-vl/UpwindContinuity.h +++ /dev/null @@ -1,385 +0,0 @@ -/*************************************************************************** - UpwindContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - static String getType() - { - return String( "UpwindContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - __cuda_callable__ - RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); - else - return density * velocity; - }; - - __cuda_callable__ - RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity; - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); - else - return 0.0; - }; - - __cuda_callable__ - RealType multiply (const RealType& a, const RealType& b ) const - { - return a * b; - }; - - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) - - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) - - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) - + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) - ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/flow-vl/UpwindEnergy.h b/src/Examples/flow-vl/UpwindEnergy.h deleted file mode 100644 index 8fa7a046a..000000000 --- a/src/Examples/flow-vl/UpwindEnergy.h +++ /dev/null @@ -1,683 +0,0 @@ -/*************************************************************************** - UpwindEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - UpwindEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "UpwindEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - }; - - void setDynamicalViscosity( const RealType& dynamicalViscosity ) - { - this->dynamicalViscosity = dynamicalViscosity; - } - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity, dynamicalViscosity; - - MeshFunctionPointer density; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - __cuda_callable__ - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) - * ( - 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - }; - - __cuda_callable__ - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) - * ( - 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) - ) -// 1D uT_11_x - - 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse / 4 - * this->dynamicalViscosity; - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) - ) -// 2D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - - velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 2D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_east - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + velocity_other2 * velocity_other2 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + velocity_other2 * velocity_other2 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) - ) -// 3D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east - - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// wT_31_x - + ( ( velocity_z_upEast * velocity_z_east - velocity_z_downEast * velocity_z_east - - velocity_z_upWest * velocity_z_west + velocity_z_downWest * velocity_z_west - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east * velocity_z_center - velocity_x_center * velocity_z_west - - velocity_x_center * velocity_z_center + velocity_x_west * velocity_z_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - + velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// wT_32_y - + ( ( velocity_z_upNorth * velocity_z_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_z_south + velocity_z_downSouth * velocity_z_south - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north * velocity_z_center - velocity_y_center * velocity_z_south - - velocity_y_center * velocity_z_center + velocity_y_south * velocity_z_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// uT_13_z - + ( ( velocity_z_up * velocity_x_center - velocity_z_center * velocity_x_center - - velocity_z_center * velocity_x_down + velocity_z_down * velocity_x_down - ) * hzSquareInverse - + ( velocity_x_upEast * velocity_x_up - velocity_x_downEast * velocity_x_down - - velocity_x_upWest * velocity_x_up + velocity_x_downWest * velocity_x_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth * velocity_y_up - velocity_y_downNorth * velocity_y_down - - velocity_y_upSouth * velocity_y_up + velocity_y_downSouth * velocity_y_down - ) * hyInverse * hzInverse / 4 - + ( velocity_z_up * velocity_y_center - velocity_z_center * velocity_y_down - - velocity_z_center * velocity_y_center + velocity_z_down * velocity_y_down - ) * hzSquareInverse - ) * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down - - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down - ) * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down - - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down - ) * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down - - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/flow-vl/UpwindMomentumBase.h b/src/Examples/flow-vl/UpwindMomentumBase.h deleted file mode 100644 index 706008b81..000000000 --- a/src/Examples/flow-vl/UpwindMomentumBase.h +++ /dev/null @@ -1,137 +0,0 @@ -/*************************************************************************** - UpwindMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setDynamicalViscosity( const RealType& dynamicalViscosity ) - { - this->dynamicalViscosity = dynamicalViscosity; - } - - __cuda_callable__ - RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) - * ( ( 2.0 * speedOfSound ) / this->gamma ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); - else - return density * velocity * velocity + pressure; - }; - - __cuda_callable__ - RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity * velocity + pressure; - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) - * ( ( 2.0 * speedOfSound ) / this->gamma ) - * ( - 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); - else - return 0; - }; - - __cuda_callable__ - RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * velocity_other; - else - return density * velocity_main * velocity_other; - }; - - __cuda_callable__ - RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity_main * velocity_other; - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * velocity_other; - else - return 0.0; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType dynamicalViscosity; - - MeshFunctionPointer density; - -}; - -} //namespace TNL diff --git a/src/Examples/flow-vl/navierStokes.cpp b/src/Examples/flow-vl/navierStokes.cpp deleted file mode 100644 index 7dffcb059..000000000 --- a/src/Examples/flow-vl/navierStokes.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "navierStokes.h" diff --git a/src/Examples/flow-vl/navierStokes.cu b/src/Examples/flow-vl/navierStokes.cu deleted file mode 100644 index 7dffcb059..000000000 --- a/src/Examples/flow-vl/navierStokes.cu +++ /dev/null @@ -1 +0,0 @@ -#include "navierStokes.h" diff --git a/src/Examples/flow-vl/navierStokesBuildConfigTag.h b/src/Examples/flow-vl/navierStokesBuildConfigTag.h deleted file mode 100644 index 78e8c57c3..000000000 --- a/src/Examples/flow-vl/navierStokesBuildConfigTag.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef navierStokesBUILDCONFIGTAG_H_ -#define navierStokesBUILDCONFIGTAG_H_ - -#include - -namespace TNL { - -class navierStokesBuildConfigTag{}; - -namespace Solvers { - -/**** - * Turn off support for float and long double. - */ -template<> struct ConfigTagReal< navierStokesBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct ConfigTagReal< navierStokesBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct ConfigTagIndex< navierStokesBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct ConfigTagIndex< navierStokesBuildConfigTag, long int >{ enum { enabled = false }; }; - -//template< int Dimension > struct ConfigTagDimension< navierStokesBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; - -/**** - * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. - */ -/* -template< int Dimension, typename Real, typename Device, typename Index > - struct ConfigTagMesh< navierStokesBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > - { enum { enabled = ConfigTagDimension< navierStokesBuildConfigTag, Dimension >::enabled && - ConfigTagReal< navierStokesBuildConfigTag, Real >::enabled && - ConfigTagDevice< navierStokesBuildConfigTag, Device >::enabled && - ConfigTagIndex< navierStokesBuildConfigTag, Index >::enabled }; }; -*/ - -/**** - * Please, chose your preferred time discretisation here. - */ -template<> struct ConfigTagTimeDiscretisation< navierStokesBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; -template<> struct ConfigTagTimeDiscretisation< navierStokesBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; -template<> struct ConfigTagTimeDiscretisation< navierStokesBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; - -/**** - * Only the Runge-Kutta-Merson solver is enabled by default. - */ -template<> struct ConfigTagExplicitSolver< navierStokesBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; - -} // namespace Solvers - -namespace Meshes { -namespace BuildConfigTags { - -template< int Dimensions > struct GridDimensionTag< navierStokesBuildConfigTag, Dimensions >{ enum { enabled = ( Dimensions == 1 ) }; }; - -/**** - * Turn off support for float and long double. - */ -template<> struct GridRealTag< navierStokesBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct GridRealTag< navierStokesBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct GridIndexTag< navierStokesBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct GridIndexTag< navierStokesBuildConfigTag, long int >{ enum { enabled = false }; }; - -} // namespace BuildConfigTags -} // namespace Meshes - -} // namespace TNL - -#endif /* navierStokesBUILDCONFIGTAG_H_ */ diff --git a/src/Examples/flow-vl/navierStokesProblem.h b/src/Examples/flow-vl/navierStokesProblem.h deleted file mode 100644 index 51cc5f014..000000000 --- a/src/Examples/flow-vl/navierStokesProblem.h +++ /dev/null @@ -1,128 +0,0 @@ -/*************************************************************************** - navierStokesProblem.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include "CompressibleConservativeVariables.h" - - -using namespace TNL::Problems; - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -class navierStokesProblem: - public PDEProblem< Mesh, - Communicator, - typename InviscidOperators::RealType, - typename Mesh::DeviceType, - typename InviscidOperators::IndexType > -{ - public: - - typedef typename InviscidOperators::RealType RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef typename InviscidOperators::IndexType IndexType; - typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; - - using typename BaseType::MeshType; - using typename BaseType::MeshPointer; - using typename BaseType::DofVectorType; - using typename BaseType::DofVectorPointer; - - static const int Dimensions = Mesh::getMeshDimension(); - - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; - typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; - typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; - using CommunicatorType = Communicator; - - static String getTypeStatic(); - - String getPrologHeader() const; - - void writeProlog( Logger& logger, - const Config::ParameterContainer& parameters ) const; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ); - - bool setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ); - - template< typename Matrix > - bool setupLinearSystem( Matrix& matrix ); - - bool makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ); - - IndexType getDofs() const; - - void bindDofs( DofVectorPointer& dofs ); - - void getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ); - - void applyBoundaryConditions( const RealType& time, - DofVectorPointer& dofs ) - { - throw Exceptions::NotImplementedError("TODO:Implement"); - } - - template< typename Matrix > - void assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs, - Matrix& matrix, - DofVectorPointer& rightHandSide ); - - bool postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ); - - protected: - - InviscidOperatorsPointer inviscidOperatorsPointer; - - BoundaryConditionPointer boundaryConditionPointer; - RightHandSidePointer rightHandSidePointer; - - ConservativeVariablesPointer conservativeVariables, - conservativeVariablesRHS; - - VelocityFieldPointer velocity; - MeshFunctionPointer pressure; - - RealType gamma; - RealType speedIncrement; - RealType cavitySpeed; - RealType speedIncrementUntil; -}; - -} // namespace TNL - -#include "navierStokesProblem_impl.h" - diff --git a/src/Examples/flow-vl/navierStokesRhs.h b/src/Examples/flow-vl/navierStokesRhs.h deleted file mode 100644 index 3c82ad453..000000000 --- a/src/Examples/flow-vl/navierStokesRhs.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef navierStokesRHS_H_ -#define navierStokesRHS_H_ - -#include - -namespace TNL { - -template< typename Mesh, typename Real >class navierStokesRhs - : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > - { - public: - - typedef Mesh MeshType; - typedef Real RealType; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; - } - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const Real& time = 0.0 ) const - { - typedef typename MeshEntity::MeshType::PointType PointType; - PointType v = entity.getCenter(); - return 0.0; - } -}; - -} //namespace TNL - -#endif /* navierStokesRHS_H_ */ diff --git a/src/Examples/flow-vl/run-navier-stokes-vl b/src/Examples/flow-vl/run-navier-stokes-vl deleted file mode 100644 index 9ebf9cbb5..000000000 --- a/src/Examples/flow-vl/run-navier-stokes-vl +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 2 \ - --origin-x 0.0 \ - --origin-y 0.0 \ - --proportions-x 1.0 \ - --proportions-y 1.0 \ - --size-x 100 \ - --size-y 100 - -tnl-init --test-function sin-wave \ - --output-file init.tnl -tnl-euler-2d --initial-condition riemann-problem \ - --discontinuity-placement-0 0.3 \ - --discontinuity-placement-1 0.3 \ - --discontinuity-placement-2 0.3 \ - --time-discretisation explicit \ - --boundary-conditions-type neumann \ - --boundary-conditions-constant 0 \ - --discrete-solver euler \ - --time-step 0.0001 \ - --snapshot-period 0.01 \ - --final-time 1.0 - -tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/flow/CMakeLists.txt b/src/Examples/flow/CMakeLists.txt deleted file mode 100644 index 6b156036b..000000000 --- a/src/Examples/flow/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -set( tnl_flow_HEADERS - CompressibleConservativeVariables.h ) - -set( tnl_flow_SOURCES - navierStokes.cpp - navierStokes.cu ) - -IF( BUILD_CUDA ) - CUDA_ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cu) -ELSE( BUILD_CUDA ) - ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cpp) -ENDIF( BUILD_CUDA ) - - -INSTALL( TARGETS tnl-navier-stokes - RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) - -INSTALL( FILES run-navier-stokes - ${tnl_inviscid_flow_SOURCES} - DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) diff --git a/src/Examples/flow/CompressibleConservativeVariables.h b/src/Examples/flow/CompressibleConservativeVariables.h deleted file mode 100644 index 01e820686..000000000 --- a/src/Examples/flow/CompressibleConservativeVariables.h +++ /dev/null @@ -1,147 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -namespace TNL { - -template< typename Mesh > -class CompressibleConservativeVariables -{ - public: - typedef Mesh MeshType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; - - CompressibleConservativeVariables(){}; - - CompressibleConservativeVariables( const MeshPointer& meshPointer ) - : density( meshPointer ), - momentum( meshPointer ), - //pressure( meshPointer ), - energy( meshPointer ){}; - - void setMesh( const MeshPointer& meshPointer ) - { - this->density->setMesh( meshPointer ); - this->momentum->setMesh( meshPointer ); - //this->pressure.setMesh( meshPointer ); - this->energy->setMesh( meshPointer ); - } - - template< typename Vector > - void bind( const MeshPointer& meshPointer, - const Vector& data, - IndexType offset = 0 ) - { - IndexType currentOffset( offset ); - this->density->bind( meshPointer, data, currentOffset ); - currentOffset += this->density->getDofs( meshPointer ); - for( IndexType i = 0; i < Dimensions; i++ ) - { - ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); - currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); - } - this->energy->bind( meshPointer, data, currentOffset ); - } - - IndexType getDofs( const MeshPointer& meshPointer ) const - { - return this->density->getDofs( meshPointer ) + - this->momentum->getDofs( meshPointer ) + - this->energy->getDofs( meshPointer ); - } - - MeshFunctionPointer& getDensity() - { - return this->density; - } - - const MeshFunctionPointer& getDensity() const - { - return this->density; - } - - void setDensity( MeshFunctionPointer& density ) - { - this->density = density; - } - - MomentumFieldPointer& getMomentum() - { - return this->momentum; - } - - const MomentumFieldPointer& getMomentum() const - { - return this->momentum; - } - - void setMomentum( MomentumFieldPointer& momentum ) - { - this->momentum = momentum; - } - - /*MeshFunctionPointer& getPressure() - { - return this->pressure; - } - - const MeshFunctionPointer& getPressure() const - { - return this->pressure; - } - - void setPressure( MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }*/ - - MeshFunctionPointer& getEnergy() - { - return this->energy; - } - - const MeshFunctionPointer& getEnergy() const - { - return this->energy; - } - - void setEnergy( MeshFunctionPointer& energy ) - { - this->energy = energy; - } - - void getVelocityField( VelocityFieldType& velocityField ) - { - - } - - protected: - - MeshFunctionPointer density; - MomentumFieldPointer momentum; - MeshFunctionPointer energy; - -}; - -} // namespace TN diff --git a/src/Examples/flow/DensityBoundaryConditionCavity.h b/src/Examples/flow/DensityBoundaryConditionCavity.h deleted file mode 100644 index c753d324a..000000000 --- a/src/Examples/flow/DensityBoundaryConditionCavity.h +++ /dev/null @@ -1,536 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class DensityBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class DensityBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return u[ neighborEntities.template getEntityIndex< 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 1, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 1 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow/EnergyBoundaryConditionCavity.h b/src/Examples/flow/EnergyBoundaryConditionCavity.h deleted file mode 100644 index 60e55f424..000000000 --- a/src/Examples/flow/EnergyBoundaryConditionCavity.h +++ /dev/null @@ -1,673 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class EnergyBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function> -class EnergyBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - ( (* this->pressure)[ neighborEntities.template getEntityIndex< 1, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - * - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - ( (* this->pressure)[ neighborEntities.template getEntityIndex< -1, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - ); - } - if( entity.getCoordinates().y() == 0 ) - { - return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 1 >() ] - / ( this->gamma - 1 ) - ) - + 0 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - ); - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, -1 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - * ( - this->cavitySpeed/* - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 )*/ - * - this->cavitySpeed/* - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 )*/ - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - ); - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - ( this->cavitySpeed - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 ) - ) - * - ( this->cavitySpeed - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 ) - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow/LaxFridrichs.h b/src/Examples/flow/LaxFridrichs.h deleted file mode 100644 index 1949bfe97..000000000 --- a/src/Examples/flow/LaxFridrichs.h +++ /dev/null @@ -1,148 +0,0 @@ -/*************************************************************************** - LaxFridrichs.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichs -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef LaxFridrichsContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); - config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); - } - - LaxFridrichs() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); - this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); - this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); - - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; - RealType dynamicalViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flow/LaxFridrichsContinuity.h b/src/Examples/flow/LaxFridrichsContinuity.h deleted file mode 100644 index bf3cc45ec..000000000 --- a/src/Examples/flow/LaxFridrichsContinuity.h +++ /dev/null @@ -1,290 +0,0 @@ -/*************************************************************************** - LaxFridrichsContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsContinuityBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - RealType artificialViscosity; -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; -// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) -// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) - - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse - + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/flow/LaxFridrichsContinuityEuler.h b/src/Examples/flow/LaxFridrichsContinuityEuler.h deleted file mode 100644 index f444a4e25..000000000 --- a/src/Examples/flow/LaxFridrichsContinuityEuler.h +++ /dev/null @@ -1,290 +0,0 @@ -/*************************************************************************** - LaxFridrichsContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsContinuityBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - RealType artificialViscosity; -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; -// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) -// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) - - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse - + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/flow/LaxFridrichsEnergy.h b/src/Examples/flow/LaxFridrichsEnergy.h deleted file mode 100644 index dd940243d..000000000 --- a/src/Examples/flow/LaxFridrichsEnergy.h +++ /dev/null @@ -1,518 +0,0 @@ -/*************************************************************************** - LaxFridrichsEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - void setDynamicalViscosity( const RealType& dynamicalViscosity ) - { - this->dynamicalViscosity = dynamicalViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity, dynamicalViscosity; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east - - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse -// 1D uT_11_x - - 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse / 4 - * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ) -// 2D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - - velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 2D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_east - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse - + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) - -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ) -// 3D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east - - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// wT_31_x - + ( ( velocity_z_upEast * velocity_z_east - velocity_z_downEast * velocity_z_east - - velocity_z_upWest * velocity_z_west + velocity_z_downWest * velocity_z_west - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east * velocity_z_center - velocity_x_center * velocity_z_west - - velocity_x_center * velocity_z_center + velocity_x_west * velocity_z_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - + velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// wT_32_y - + ( ( velocity_z_upNorth * velocity_z_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_z_south + velocity_z_downSouth * velocity_z_south - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north * velocity_z_center - velocity_y_center * velocity_z_south - - velocity_y_center * velocity_z_center + velocity_y_south * velocity_z_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// uT_13_z - + ( ( velocity_z_up * velocity_x_center - velocity_z_center * velocity_x_center - - velocity_z_center * velocity_x_down + velocity_z_down * velocity_x_down - ) * hzSquareInverse - + ( velocity_x_upEast * velocity_x_up - velocity_x_downEast * velocity_x_down - - velocity_x_upWest * velocity_x_up + velocity_x_downWest * velocity_x_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth * velocity_y_up - velocity_y_downNorth * velocity_y_down - - velocity_y_upSouth * velocity_y_up + velocity_y_downSouth * velocity_y_down - ) * hyInverse * hzInverse / 4 - + ( velocity_z_up * velocity_y_center - velocity_z_center * velocity_y_down - - velocity_z_center * velocity_y_center + velocity_z_down * velocity_y_down - ) * hzSquareInverse - ) * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down - - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down - ) * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down - - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down - ) * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down - - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/flow/LaxFridrichsEnergyEuler.h b/src/Examples/flow/LaxFridrichsEnergyEuler.h deleted file mode 100644 index 30180639d..000000000 --- a/src/Examples/flow/LaxFridrichsEnergyEuler.h +++ /dev/null @@ -1,309 +0,0 @@ -/*************************************************************************** - LaxFridrichsEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east - - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse; - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse - + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) - -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/flow/LaxFridrichsEuler.h b/src/Examples/flow/LaxFridrichsEuler.h deleted file mode 100644 index c56d20aed..000000000 --- a/src/Examples/flow/LaxFridrichsEuler.h +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - LaxFridrichs.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichs -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef LaxFridrichsContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); - } - - LaxFridrichs() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); - this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); - - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flow/LaxFridrichsMomentumBase.h b/src/Examples/flow/LaxFridrichsMomentumBase.h deleted file mode 100644 index 79005b55e..000000000 --- a/src/Examples/flow/LaxFridrichsMomentumBase.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsMomentumBase() - : artificialViscosity( 1.0 ){}; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - void setDynamicalViscosity( const RealType& dynamicalViscosity ) - { - this->dynamicalViscosity = dynamicalViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity, dynamicalViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flow/LaxFridrichsMomentumBaseEuler.h b/src/Examples/flow/LaxFridrichsMomentumBaseEuler.h deleted file mode 100644 index cc2561748..000000000 --- a/src/Examples/flow/LaxFridrichsMomentumBaseEuler.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsMomentumBase() - : artificialViscosity( 1.0 ){}; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flow/LaxFridrichsMomentumX.h b/src/Examples/flow/LaxFridrichsMomentumX.h deleted file mode 100644 index 3e295c029..000000000 --- a/src/Examples/flow/LaxFridrichsMomentumX.h +++ /dev/null @@ -1,383 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse -// 1D T_11_x - - 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ) -// 2D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_21_y - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south - ) * hxInverse * hyInverse - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_u[ up ] * velocity_z_up ) - - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ) -// 3D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_21_x - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// T_31_x - + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow/LaxFridrichsMomentumXEuler.h b/src/Examples/flow/LaxFridrichsMomentumXEuler.h deleted file mode 100644 index 63def12d3..000000000 --- a/src/Examples/flow/LaxFridrichsMomentumXEuler.h +++ /dev/null @@ -1,276 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - //const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - //const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - //const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - //const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_u[ up ] * velocity_z_up ) - - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow/LaxFridrichsMomentumY.h b/src/Examples/flow/LaxFridrichsMomentumY.h deleted file mode 100644 index 0df12c522..000000000 --- a/src/Examples/flow/LaxFridrichsMomentumY.h +++ /dev/null @@ -1,363 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ) -// 2D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_12_x - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east - ) * hxSquareInverse - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse - + ( ( rho_v[ up ] * velocity_z_up ) - - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ) -// T_12_y - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_32_y - + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow/LaxFridrichsMomentumYEuler.h b/src/Examples/flow/LaxFridrichsMomentumYEuler.h deleted file mode 100644 index 8ce42282d..000000000 --- a/src/Examples/flow/LaxFridrichsMomentumYEuler.h +++ /dev/null @@ -1,260 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse - + ( ( rho_v[ up ] * velocity_z_up ) - - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow/LaxFridrichsMomentumZ.h b/src/Examples/flow/LaxFridrichsMomentumZ.h deleted file mode 100644 index e4f8501ec..000000000 --- a/src/Examples/flow/LaxFridrichsMomentumZ.h +++ /dev/null @@ -1,314 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) - -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) - - ( rho_w[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_w[ north ] * velocity_y_north ) - - ( rho_w[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) - - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ) -// T_13_z - + ( ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - + ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - ) - * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow/LaxFridrichsMomentumZEuler.h b/src/Examples/flow/LaxFridrichsMomentumZEuler.h deleted file mode 100644 index a67e862ce..000000000 --- a/src/Examples/flow/LaxFridrichsMomentumZEuler.h +++ /dev/null @@ -1,240 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) - -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) - - ( rho_w[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_w[ north ] * velocity_y_north ) - - ( rho_w[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) - - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow/PhysicalVariablesGetter.h b/src/Examples/flow/PhysicalVariablesGetter.h deleted file mode 100644 index d7eeb7618..000000000 --- a/src/Examples/flow/PhysicalVariablesGetter.h +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { - -template< typename Mesh > -class PhysicalVariablesGetter -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - VelocityGetter( MeshFunctionPointer density, - MeshFunctionPointer momentum ) - : density( density ), momentum( momentum ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) - return 0; - else - return momentum.template getData< DeviceType >()( meshEntity ) / - density.template getData< DeviceType >()( meshEntity ); - } - - protected: - const MeshFunctionPointer density, momentum; - }; - - class PressureGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - PressureGetter( MeshFunctionPointer density, - MeshFunctionPointer energy, - VelocityFieldPointer momentum, - const RealType& gamma ) - : density( density ), energy( energy ), momentum( momentum ), gamma( gamma ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - const RealType e = energy.template getData< DeviceType >()( meshEntity ); - const RealType rho = density.template getData< DeviceType >()( meshEntity ); - const RealType momentumNorm = lpNorm( momentum.template getData< DeviceType >().getVector( meshEntity ), 2.0 ); - if( rho == 0.0 ) - return 0; - else - return ( gamma - 1.0 ) * ( e - 0.5 * momentumNorm * momentumNorm / rho ); - } - - protected: - const MeshFunctionPointer density, energy; - const VelocityFieldPointer momentum; - const RealType gamma; - }; - - - void getVelocity( const ConservativeVariablesPointer& conservativeVariables, - VelocityFieldPointer& velocity ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; - for( int i = 0; i < Dimensions; i++ ) - { - Pointers::SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), - ( *conservativeVariables->getMomentum() )[ i ] ); - evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); - } - } - - void getPressure( const ConservativeVariablesPointer& conservativeVariables, - const RealType& gamma, - MeshFunctionPointer& pressure ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; - Pointers::SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), - conservativeVariables->getEnergy(), - conservativeVariables->getMomentum(), - gamma ); - evaluator.evaluate( pressure, pressureGetter ); - } - -}; - -} //namespace TNL diff --git a/src/Examples/flow/RiemannProblemInitialCondition.h b/src/Examples/flow/RiemannProblemInitialCondition.h deleted file mode 100644 index 481a45bba..000000000 --- a/src/Examples/flow/RiemannProblemInitialCondition.h +++ /dev/null @@ -1,1413 +0,0 @@ -/*************************************************************************** - RiemannProblemInitialCondition.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -template -class RiemannProblemInitialConditionSetter -{ - -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 1,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 2,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template< typename Mesh > -class RiemannProblemInitialCondition -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; - - RiemannProblemInitialCondition() - : discontinuityPlacement( 0.5 ), - leftDensity( 1.0 ), rightDensity( 1.0 ), - leftVelocity( -2.0 ), rightVelocity( 2.0 ), - leftPressure( 0.4 ), rightPressure( 0.4 ), - gamma( 1.67 ){} - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "discontinuity-placement-0", "x-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-1", "y-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-2", "z-coordinate of the discontinuity placement.", 0.5 ); -/* - config.addEntry< double >( prefix + "left-density", "Density on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-density", "Density on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-velocity-0", "x-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-1", "y-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-2", "z-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-velocity-0", "x-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-1", "y-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-2", "z-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-pressure", "Pressure on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-pressure", "Pressure on the right side of the discontinuity.", 0.0 ); -*/ - config.addEntry< double >( prefix + "NWU-density", "This sets a value of northwest up density.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-0", "This sets a value of northwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-1", "This sets a value of northwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-2", "This sets a value of northwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-pressure", "This sets a value of northwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWU-density", "This sets a value of southwest up density.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-0", "This sets a value of southwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-1", "This sets a value of southwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-2", "This sets a value of southwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-pressure", "This sets a value of southwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NWD-density", "This sets a value of northwest down density.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-0", "This sets a value of northwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-1", "This sets a value of northwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-2", "This sets a value of northwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-pressure", "This sets a value of northwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWD-density", "This sets a value of southwest down density.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-0", "This sets a value of southwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-1", "This sets a value of southwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-2", "This sets a value of southwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-pressure", "This sets a value of southwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "NEU-density", "This sets a value of northeast up density.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-0", "This sets a value of northeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-1", "This sets a value of northeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-2", "This sets a value of northeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-pressure", "This sets a value of northeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SEU-density", "This sets a value of southeast up density.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-0", "This sets a value of southeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-1", "This sets a value of southeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-2", "This sets a value of southeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-pressure", "This sets a value of southeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NED-density", "This sets a value of northeast down density.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-0", "This sets a value of northeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-1", "This sets a value of northeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-2", "This sets a value of northeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-pressure", "This sets a value of northeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SED-density", "This sets a value of southeast down density.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-0", "This sets a value of southeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-1", "This sets a value of southeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-2", "This sets a value of southeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-pressure", "This sets a value of southeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "gamma", "Gamma in the ideal gas state equation.", 1.4 ); - - config.addEntry< String >( prefix + "initial", " One of predefined initial condition.", "none"); - config.addEntryEnum< String >( "none" ); - config.addEntryEnum< String >( "1D_2" ); - config.addEntryEnum< String >( "1D_3a" ); - config.addEntryEnum< String >( "1D_4" ); - config.addEntryEnum< String >( "1D_5" ); - config.addEntryEnum< String >( "1D_6" ); - config.addEntryEnum< String >( "1D_Noh" ); - config.addEntryEnum< String >( "1D_peak" ); - config.addEntryEnum< String >( "2D_3" ); - config.addEntryEnum< String >( "2D_4" ); - config.addEntryEnum< String >( "2D_6" ); - config.addEntryEnum< String >( "2D_12" ); - config.addEntryEnum< String >( "2D_15" ); - config.addEntryEnum< String >( "2D_17" ); - } - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - String initial = parameters.getParameter< String >( prefix + "initial" ); - if(initial == prefix + "none") - { - this->discontinuityPlacement.setup( parameters, prefix + "discontinuity-placement-" ); - this->gamma = parameters.getParameter< double >( prefix + "gamma" ); -/* - this->leftVelocity.setup( parameters, prefix + "left-velocity-" ); - this->rightVelocity.setup( parameters, prefix + "right-velocity-" ); - this->leftDensity = parameters.getParameter< double >( prefix + "left-density" ); - this->rightDensity = parameters.getParameter< double >( prefix + "right-density" ); - this->leftPressure = parameters.getParameter< double >( prefix + "left-pressure" ); - this->rightPressure = parameters.getParameter< double >( prefix + "right-pressure" ); -*/ - - this->NWUDensity = parameters.getParameter< RealType >( prefix + "NWU-density" ); - this->NWUVelocity.setup( parameters, prefix + "NWU-velocity-" ); - this->NWUPressure = parameters.getParameter< RealType >( prefix + "NWU-pressure" ); - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); - this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); - this->SWUPressure = parameters.getParameter< RealType >( prefix + "SWU-pressure" ); - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); - this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); - this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); - this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); - this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); - this->SWDPressure = parameters.getParameter< RealType >( prefix + "SWD-pressure" ); - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); - this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); - this->NEUPressure = parameters.getParameter< RealType >( prefix + "NEU-pressure" ); - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); - this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); - this->SEUPressure = parameters.getParameter< RealType >( prefix + "SEU-pressure" ); - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); - this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); - this->NEDPressure = parameters.getParameter< RealType >( prefix + "NED-pressure" ); - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); - this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); - this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - - } - if(initial == prefix + "1D_2") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -2.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_3a") - predefinedInitialCondition( 1.4, 0.8, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1000.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.01, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -19.59745, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -19.57945, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_4") - predefinedInitialCondition( 1.666, 0.4, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 5.99924, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 5.99242, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 460.894, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 46.095, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 19.5975, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -6.19633, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_5") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_6") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.1, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_Noh") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.000001, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.000001, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_peak") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 0.12612, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 6.5915, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 782.929, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 3.15449, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 8.90470, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.26542, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_3") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5323, 0.138, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.5, 0.5323, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.3, 0.029, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.5, 0.3, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 1.206, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.206, 1.206, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.206, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_4") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5065, 1.1, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.1, 0.5065, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.35, 1.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.1, 0.35, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.8939, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.8939, 0.8939, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.8939, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_6") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 3.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.75, 0.5, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -0.75, 0.5, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.75, -0.5, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -0.75, -0.5, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_12") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 1.0, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.5313, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.4, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.7276, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.7276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_15") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5197, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5313, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.4, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - -0.6259, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.1, -0.3, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.1, -0.3, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.1, 0.4276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_17") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0625, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5197, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.2145, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, -0.4, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.1259, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - return true; - } - - void setDiscontinuityPlacement( const PointType& v ) - { - this->discontinuityPlacement = v; - } - - const PointType& getDiscontinuityPlasement() const - { - return this->discontinuityPlacement; - } - - void setLeftDensity( const RealType& leftDensity ) - { - this->leftDensity = leftDensity; - } - - const RealType& getLeftDensity() const - { - return this->leftDensity; - } - - void setRightDensity( const RealType& rightDensity ) - { - this->rightDensity = rightDensity; - } - - const RealType& getRightDensity() const - { - return this->rightDensity; - } - - void setLeftVelocity( const PointType& leftVelocity ) - { - this->leftVelocity = leftVelocity; - } - - const PointType& getLeftVelocity() const - { - return this->leftVelocity; - } - - void setRightVelocity( const RealType& rightVelocity ) - { - this->rightVelocity = rightVelocity; - } - - const PointType& getRightVelocity() const - { - return this->rightVelocity; - } - - void setLeftPressure( const RealType& leftPressure ) - { - this->leftPressure = leftPressure; - } - - const RealType& getLeftPressure() const - { - return this->leftPressure; - } - - void setRightPressure( const RealType& rightPressure ) - { - this->rightPressure = rightPressure; - } - - const RealType& getRightPressure() const - { - return this->rightPressure; - } - - - void predefinedInitialCondition( double preGamma, double preDiscX, double preDiscY, double preDiscZ, - double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ) - - { - this->discontinuityPlacement = PointLoad(preDiscX, preDiscY, preDiscZ); - this->gamma = preGamma; - - this->NWUDensity = preNWUDensity; - this->NWUVelocity = PointLoad(preNWUVelocityX, preNWUVelocityY, preNWUVelocityZ); - this->NWUPressure = preNWUPressure; - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = preNWUDensity; - this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); - this->SWUPressure = preSWUPressure; - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = preNWDDensity; - this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); - this->NWDPressure = preNWDPressure; - this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = preSWDDensity; - this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); - this->SWDPressure = preSWDPressure; - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = preNEUDensity; - this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); - this->NEUPressure = preNEUPressure; - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = preSEUDensity; - this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); - this->SEUPressure = preSEUPressure; - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = preNEDDensity; - this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); - this->NEDPressure = preNEDPressure; - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = preSEDDensity; - this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); - this->SEDPressure = preSEDPressure; - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - } - - PointType PointLoad( RealType ValueX, RealType ValueY, RealType ValueZ) - { - PointType point; - switch (Dimensions) - { - case 1: point[ 0 ] = ValueX; - break; - case 2: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - break; - case 3: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - point[ 2 ] = ValueZ; - break; - } - return point; - } - - RealType Energy( RealType Density, RealType Pressure, RealType gamma, PointType Velocity) - { - RealType energy; - switch (Dimensions) - { - case 1: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ))); - break; - case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); - break; - case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 3 ], 2 ))); - break; // druhou mocninu ps8t jako sou4in - } - return energy; - } - - void setInitialCondition( CompressibleConservativeVariables< MeshType >& conservativeVariables, - const PointType& center = PointType( 0.0 ) ) - { - RiemannProblemInitialConditionSetter* variablesSetter = new RiemannProblemInitialConditionSetter; - variablesSetter->setGamma(this->gamma); - variablesSetter->setDensity(this->NWUDensity, - this->NEUDensity, - this->SWUDensity, - this->SEUDensity, - this->NWDDensity, - this->NEDDensity, - this->SWDDensity, - this->SEDDensity); - variablesSetter->setMomentum(this->NWUMomentum, - this->NEUMomentum, - this->SWUMomentum, - this->SEUMomentum, - this->NWDMomentum, - this->NEDMomentum, - this->SWDMomentum, - this->SEDMomentum); - variablesSetter->setEnergy(this->NWUEnergy, - this->NEUEnergy, - this->SWUEnergy, - this->SEUEnergy, - this->NWDEnergy, - this->NEDEnergy, - this->SWDEnergy, - this->SEDEnergy); - variablesSetter->setDiscontinuity(this->discontinuityPlacement); - variablesSetter->placeDensity(conservativeVariables); - variablesSetter->placeMomentum(conservativeVariables); - variablesSetter->placeEnergy(conservativeVariables); - -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - -/* - typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; - typedef Operators::Analytic::Sign< Dimensions, RealType > SignType; - typedef Functions::OperatorFunction< SignType, VectorNormType > InitialConditionType; - typedef Pointers::SharedPointer< InitialConditionType, DeviceType > InitialConditionPointer; - - InitialConditionPointer initialCondition; - initialCondition->getFunction().setCenter( center ); - initialCondition->getFunction().setMaxNorm( true ); - initialCondition->getFunction().setRadius( discontinuityPlacement[ 0 ] ); - discontinuityPlacement *= 1.0 / discontinuityPlacement[ 0 ]; - for( int i = 1; i < Dimensions; i++ ) - discontinuityPlacement[ i ] = 1.0 / discontinuityPlacement[ i ]; - initialCondition->getFunction().setAnisotropy( discontinuityPlacement ); - initialCondition->getFunction().setMultiplicator( -1.0 ); - - Functions::MeshFunctionEvaluator< MeshFunctionType, InitialConditionType > evaluator; -*/ - /**** - * Density - */ -/* - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ -/* - initialCondition->getOperator().setPositiveValue( leftDensity ); - initialCondition->getOperator().setNegativeValue( rightDensity ); - evaluator.evaluate( conservativeVariables.getDensity(), initialCondition ); - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ - /**** - * Momentum - */ - -/* - for( int i = 0; i < Dimensions; i++ ) - { - initialCondition->getOperator().setPositiveValue( leftDensity * leftVelocity[ i ] ); - initialCondition->getOperator().setNegativeValue( rightDensity * rightVelocity[ i ] ); - evaluator.evaluate( conservativeVariables.getMomentum()[ i ], initialCondition ); - } -*/ - /**** - * Energy - */ -/* - conservativeVariables.getEnergy()->write( "energy-init", "gnuplot" ); -*/ -/* - const RealType leftKineticEnergy = leftVelocity.lpNorm( 2.0 ); - const RealType rightKineticEnergy = rightVelocity.lpNorm( 2.0 ); - const RealType leftEnergy = leftPressure / ( gamma - 1.0 ) + 0.5 * leftDensity * leftKineticEnergy * leftKineticEnergy; - const RealType rightEnergy = rightPressure / ( gamma - 1.0 ) + 0.5 * rightDensity * rightKineticEnergy * rightKineticEnergy; - initialCondition->getOperator().setPositiveValue( leftEnergy ); - initialCondition->getOperator().setNegativeValue( rightEnergy ); - evaluator.evaluate( (* conservativeVariables.getEnergy()), initialCondition ); - (* conservativeVariables.getEnergy())->write( "energy-init", "gnuplot" ); -*/ - } - - - protected: - - PointType discontinuityPlacement; - PointType NWUVelocity, NEUVelocity, SWUVelocity, SEUVelocity, NWDVelocity, NEDVelocity, SWDVelocity, SEDVelocity; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUPressure, NEUPressure, SWUPressure, SEUPressure, NWDPressure, NEDPressure, SWDPressure, SEDPressure; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType leftDensity, rightDensity; - PointType leftVelocity, rightVelocity; - RealType leftPressure, rightPressure; - - RealType gamma; // gamma in the ideal gas state equation -}; - -} //namespace TNL diff --git a/src/Examples/flow/navierStokes.h b/src/Examples/flow/navierStokes.h deleted file mode 100644 index 5b37345bc..000000000 --- a/src/Examples/flow/navierStokes.h +++ /dev/null @@ -1,108 +0,0 @@ -#include -#include -#include -#include -#include -#include "navierStokesProblem.h" -#include "LaxFridrichs.h" -#include "navierStokesRhs.h" -#include "navierStokesBuildConfigTag.h" - -#include "RiemannProblemInitialCondition.h" -#include "BoundaryConditionsCavity.h" -#include "BoundaryConditionsBoiler.h" - -using namespace TNL; - -typedef navierStokesBuildConfigTag BuildConfig; - -/**** - * Uncomment the following (and comment the previous line) for the complete build. - * This will include support for all floating point precisions, all indexing types - * and more solvers. You may then choose between them from the command line. - * The compile time may, however, take tens of minutes or even several hours, - * especially if CUDA is enabled. Use this, if you want, only for the final build, - * not in the development phase. - */ -//typedef tnlDefaultConfigTag BuildConfig; - -template< typename ConfigTag >class navierStokesConfig -{ - public: - static void configSetup( Config::ConfigDescription & config ) - { - config.addDelimiter( "Inviscid flow settings:" ); - config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); - config.addEntryEnum< String >( "boiler" ); - config.addEntryEnum< String >( "cavity" ); - config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); - config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); - config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); - config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); - typedef Meshes::Grid< 3 > Mesh; - LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); - RiemannProblemInitialCondition< Mesh >::configSetup( config ); - - /**** - * Add definition of your solver command line arguments. - */ - - } -}; - -template< typename Real, - typename Device, - typename Index, - typename MeshType, - typename ConfigTag, - typename SolverStarter, - typename Communicator > -class navierStokesSetter -{ - public: - - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - static bool run( const Config::ParameterContainer & parameters ) - { - enum { Dimension = MeshType::getMeshDimension() }; - typedef LaxFridrichs< MeshType, Real, Index > ApproximateOperator; - typedef navierStokesRhs< MeshType, Real > RightHandSide; - typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; - - /**** - * Resolve the template arguments of your solver here. - * The following code is for the Dirichlet and the Neumann boundary conditions. - * Both can be constant or defined as descrete values of Vector. - */ - - typedef Functions::Analytic::Constant< Dimension, Real > Constant; - String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); - if( boundaryConditionsType == "cavity" ) - { - typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; - typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "boiler" ) - { - typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; - typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - - return true;} - -}; - -int main( int argc, char* argv[] ) -{ - Solvers::Solver< navierStokesSetter, navierStokesConfig, BuildConfig > solver; - if( ! solver. run( argc, argv ) ) - return EXIT_FAILURE; - return EXIT_SUCCESS; -}; diff --git a/src/Examples/flow/navierStokesProblem.h b/src/Examples/flow/navierStokesProblem.h deleted file mode 100644 index f42c2ed09..000000000 --- a/src/Examples/flow/navierStokesProblem.h +++ /dev/null @@ -1,128 +0,0 @@ -/*************************************************************************** - navierStokesProblem.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include "CompressibleConservativeVariables.h" - - -using namespace TNL::Problems; - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -class navierStokesProblem: - public PDEProblem< Mesh, - Communicator, - typename InviscidOperators::RealType, - typename Mesh::DeviceType, - typename InviscidOperators::IndexType > -{ - public: - - typedef typename InviscidOperators::RealType RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef typename InviscidOperators::IndexType IndexType; - typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; - - using typename BaseType::MeshType; - using typename BaseType::MeshPointer; - using typename BaseType::DofVectorType; - using typename BaseType::DofVectorPointer; - - static const int Dimensions = Mesh::getMeshDimension(); - - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; - typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; - typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; - using CommunicatorType = Communicator; - - static String getTypeStatic(); - - String getPrologHeader() const; - - void writeProlog( Logger& logger, - const Config::ParameterContainer& parameters ) const; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ); - - bool setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ); - - template< typename Matrix > - bool setupLinearSystem( Matrix& matrix ); - - bool makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ); - - IndexType getDofs() const; - - void bindDofs(DofVectorPointer& dofs ); - - void getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ); - - void applyBoundaryConditions( const RealType& time, - DofVectorPointer& dofs ) - { - throw Exceptions::NotImplementedError("TODO:Implement"); - } - - template< typename Matrix > - void assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs, - Matrix& matrix, - DofVectorPointer& rightHandSide ); - - bool postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ); - - protected: - - InviscidOperatorsPointer inviscidOperatorsPointer; - - BoundaryConditionPointer boundaryConditionPointer; - RightHandSidePointer rightHandSidePointer; - - ConservativeVariablesPointer conservativeVariables, - conservativeVariablesRHS; - - VelocityFieldPointer velocity; - MeshFunctionPointer pressure; - - RealType gamma; - RealType speedIncrement; - RealType cavitySpeed; - RealType speedIncrementUntil; -}; - -} // namespace TNL - -#include "navierStokesProblem_impl.h" - diff --git a/src/Examples/flow/navierStokesProblem_impl.h b/src/Examples/flow/navierStokesProblem_impl.h deleted file mode 100644 index 4b0c79774..000000000 --- a/src/Examples/flow/navierStokesProblem_impl.h +++ /dev/null @@ -1,464 +0,0 @@ -/*************************************************************************** - navierStokesProblem_impl.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -#include "RiemannProblemInitialCondition.h" -#include "CompressibleConservativeVariables.h" -#include "PhysicalVariablesGetter.h" -#include "navierStokesProblem.h" - -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" -/* -#include "DensityBoundaryConditionCavity.h" -#include "MomentumXBoundaryConditionCavity.h" -#include "MomentumYBoundaryConditionCavity.h" -#include "MomentumZBoundaryConditionCavity.h" -#include "EnergyBoundaryConditionCavity.h" - -#include "DensityBoundaryConditionBoiler.h" -#include "MomentumXBoundaryConditionBoiler.h" -#include "MomentumYBoundaryConditionBoiler.h" -#include "MomentumZBoundaryConditionBoiler.h" -#include "EnergyBoundaryConditionBoiler.h" -*/ -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -String -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getTypeStatic() -{ - return String( "navierStokesProblem< " ) + Mesh :: getTypeStatic() + " >"; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -String -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getPrologHeader() const -{ - return String( "Inviscid flow solver" ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const -{ - /**** - * Add data you want to have in the computation report (log) as follows: - * logger.writeParameter< double >( "Parameter description", parameter ); - */ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setup( const Config::ParameterContainer& parameters, - const String& prefix ) -{ - if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || - ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || - ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) - return false; - this->gamma = parameters.getParameter< double >( "gamma" ); - velocity->setMesh( this->getMesh() ); - pressure->setMesh( this->getMesh() ); - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -typename navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >::IndexType -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getDofs() const -{ - /**** - * Return number of DOFs (degrees of freedom) i.e. number - * of unknowns to be resolved by the main solver. - */ - return this->conservativeVariables->getDofs( this->getMesh() ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -bindDofs( DofVectorPointer& dofVector ) -{ - this->conservativeVariables->bind( this->getMesh(), dofVector ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ) -{ - CompressibleConservativeVariables< MeshType > conservativeVariables; - conservativeVariables.bind( this->getMesh(), dofs ); - const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); - this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); - this->speedIncrement = parameters.getParameter< RealType >( "speed-increment" ); - this->cavitySpeed = parameters.getParameter< RealType >( "cavity-speed" ); - if( initialConditionType == "riemann-problem" ) - { - RiemannProblemInitialCondition< MeshType > initialCondition; - if( ! initialCondition.setup( parameters ) ) - return false; - initialCondition.setInitialCondition( conservativeVariables ); - return true; - } - std::cerr << "Unknown initial condition " << initialConditionType << std::endl; - return false; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > - template< typename Matrix > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setupLinearSystem( Matrix& matrix ) -{ -/* const IndexType dofs = this->getDofs( mesh ); - typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; - CompressedRowLengthsVectorType rowLengths; - if( ! rowLengths.setSize( dofs ) ) - return false; - MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; - matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, - differentialOperator, - boundaryCondition, - rowLengths ); - matrix.setDimensions( dofs, dofs ); - if( ! matrix.setCompressedRowLengths( rowLengths ) ) - return false;*/ - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ) -{ - std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; - - this->bindDofs( dofs ); - PhysicalVariablesGetter< MeshType > physicalVariablesGetter; - physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - FileName fileName; - fileName.setExtension( "tnl" ); - fileName.setIndex( step ); - fileName.setFileNameBase( "density-" ); -// if( ! this->conservativeVariables->getDensity()->save( fileName.getFileName() ) ) -// return false; - - fileName.setFileNameBase( "velocity-" ); - this->velocity->save( fileName.getFileName() ); - -// fileName.setFileNameBase( "pressure-" ); -// if( ! this->pressure->save( fileName.getFileName() ) ) -// return false; - -// fileName.setFileNameBase( "energy-" ); -// if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) -// return false; - -// fileName.setFileNameBase( "momentum-" ); -// if( ! this->conservativeVariables->getMomentum()->save( fileName.getFileName() ) ) -// return false; - - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ) -{ - typedef typename MeshType::Cell Cell; - const MeshPointer& mesh = this->getMesh(); - - /**** - * Bind DOFs - */ - this->conservativeVariables->bind( mesh, _u ); - this->conservativeVariablesRHS->bind( mesh, _fu ); - this->velocity->setMesh( mesh ); - this->pressure->setMesh( mesh ); - - /**** - * Resolve the physical variables - */ - PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; - physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - /**** - * Set-up operators - */ - typedef typename InviscidOperators::ContinuityOperatorType ContinuityOperatorType; - typedef typename InviscidOperators::MomentumXOperatorType MomentumXOperatorType; - typedef typename InviscidOperators::MomentumYOperatorType MomentumYOperatorType; - typedef typename InviscidOperators::MomentumZOperatorType MomentumZOperatorType; - typedef typename InviscidOperators::EnergyOperatorType EnergyOperatorType; - - this->inviscidOperatorsPointer->setTau( tau ); - this->inviscidOperatorsPointer->setVelocity( this->velocity ); - this->inviscidOperatorsPointer->setPressure( this->pressure ); - - /**** - * Set Up Boundary Conditions - */ - - typedef typename BoundaryCondition::DensityBoundaryConditionsType DensityBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumXBoundaryConditionsType MomentumXBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumYBoundaryConditionsType MomentumYBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumZBoundaryConditionsType MomentumZBoundaryConditionsType; - typedef typename BoundaryCondition::EnergyBoundaryConditionsType EnergyBoundaryConditionsType; - - /**** - * Update Boundary Conditions - */ - if(this->speedIncrementUntil > time ) - { - this->boundaryConditionPointer->setTimestep(this->speedIncrement); - } - else - { - this->boundaryConditionPointer->setTimestep(0); - } - this->boundaryConditionPointer->setSpeed(this->cavitySpeed); - this->boundaryConditionPointer->setCompressibleConservativeVariables(this->conservativeVariables); - this->boundaryConditionPointer->setGamma(this->gamma); - this->boundaryConditionPointer->setPressure(this->pressure); - - /**** - * Continuity equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, ContinuityOperatorType, DensityBoundaryConditionsType, RightHandSide > explicitUpdaterContinuity; - explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); - explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer->getDensityBoundaryCondition() ); - explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterContinuity.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - this->conservativeVariables->getDensity(), - this->conservativeVariablesRHS->getDensity() ); - /**** - * Momentum equations - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumXOperatorType, MomentumXBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumX; - explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); - explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer->getMomentumXBoundaryCondition() ); - explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumX.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); - - if( Dimensions > 1 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumYOperatorType, MomentumYBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumY; - explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); - explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer->getMomentumYBoundaryCondition() ); - explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumY.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); - } - - if( Dimensions > 2 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, MomentumZBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumZ; - explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); - explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer->getMomentumZBoundaryCondition() ); - explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumZ.template update< typename Mesh::Cell, CommunicatorType >( time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); - } - - /**** - * Energy equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, EnergyOperatorType, EnergyBoundaryConditionsType, RightHandSide > explicitUpdaterEnergy; - explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); - explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer->getEnergyBoundaryCondition() ); - explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterEnergy.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - this->conservativeVariables->getEnergy(), // uRhoVelocityX, - this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); - - /* - this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); - this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); - this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); - getchar(); - */ - -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > - template< typename Matrix > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - Matrix& matrix, - DofVectorPointer& b ) -{ -/* LinearSystemAssembler< Mesh, - MeshFunctionType, - InviscidOperators, - BoundaryCondition, - RightHandSide, - BackwardTimeDiscretisation, - Matrix, - DofVectorType > systemAssembler; - - MeshFunction< Mesh > u( mesh, _u ); - systemAssembler.template assembly< typename Mesh::Cell >( time, - tau, - mesh, - this->differentialOperator, - this->boundaryCondition, - this->rightHandSide, - u, - matrix, - b );*/ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ) -{ - /* - typedef typename MeshType::Cell Cell; - int count = mesh->template getEntitiesCount< Cell >()/4; - //bind _u - this->_uRho.bind( *dofs, 0, count); - this->_uRhoVelocityX.bind( *dofs, count, count); - this->_uRhoVelocityY.bind( *dofs, 2 * count, count); - this->_uEnergy.bind( *dofs, 3 * count, count); - - MeshFunctionType velocity( mesh, this->velocity ); - MeshFunctionType velocityX( mesh, this->velocityX ); - MeshFunctionType velocityY( mesh, this->velocityY ); - MeshFunctionType pressure( mesh, this->pressure ); - MeshFunctionType uRho( mesh, _uRho ); - MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); - MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); - MeshFunctionType uEnergy( mesh, _uEnergy ); - //Generating differential operators - Velocity navierStokes2DVelocity; - VelocityX navierStokes2DVelocityX; - VelocityY navierStokes2DVelocityY; - Pressure navierStokes2DPressure; - - //velocityX - navierStokes2DVelocityX.setRhoVelX(uRhoVelocityX); - navierStokes2DVelocityX.setRho(uRho); -// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; -// velocityX = OFVelocityX; - - //velocityY - navierStokes2DVelocityY.setRhoVelY(uRhoVelocityY); - navierStokes2DVelocityY.setRho(uRho); -// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; -// velocityY = OFVelocityY; - - //velocity - navierStokes2DVelocity.setVelX(velocityX); - navierStokes2DVelocity.setVelY(velocityY); -// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; -// velocity = OFVelocity; - - //pressure - navierStokes2DPressure.setGamma(gamma); - navierStokes2DPressure.setVelocity(velocity); - navierStokes2DPressure.setEnergy(uEnergy); - navierStokes2DPressure.setRho(uRho); -// OperatorFunction< navierStokes2DPressure, MeshFunction, void, time > OFPressure; -// pressure = OFPressure; - */ - return true; -} - -} // namespace TNL - diff --git a/src/Examples/flow/run-navier-stokes b/src/Examples/flow/run-navier-stokes deleted file mode 100644 index 9ebf9cbb5..000000000 --- a/src/Examples/flow/run-navier-stokes +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 2 \ - --origin-x 0.0 \ - --origin-y 0.0 \ - --proportions-x 1.0 \ - --proportions-y 1.0 \ - --size-x 100 \ - --size-y 100 - -tnl-init --test-function sin-wave \ - --output-file init.tnl -tnl-euler-2d --initial-condition riemann-problem \ - --discontinuity-placement-0 0.3 \ - --discontinuity-placement-1 0.3 \ - --discontinuity-placement-2 0.3 \ - --time-discretisation explicit \ - --boundary-conditions-type neumann \ - --boundary-conditions-constant 0 \ - --discrete-solver euler \ - --time-step 0.0001 \ - --snapshot-period 0.01 \ - --final-time 1.0 - -tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/inviscid-flow-sw/CMakeLists.txt b/src/Examples/inviscid-flow-sw/CMakeLists.txt deleted file mode 100644 index 427def126..000000000 --- a/src/Examples/inviscid-flow-sw/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -set( tnl_inviscid_flow_sw_HEADERS - CompressibleConservativeVariables.h ) - -set( tnl_inviscid_flow_sw_SOURCES - euler.cpp - euler.cu ) - -IF( BUILD_CUDA ) - CUDA_ADD_EXECUTABLE(tnl-euler-sw euler.cu) -ELSE( BUILD_CUDA ) - ADD_EXECUTABLE(tnl-euler-sw${debugExt} euler.cpp) -ENDIF( BUILD_CUDA ) - - -INSTALL( TARGETS tnl-euler-sw - RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) - -INSTALL( FILES run-euler-sw - ${tnl_inviscid_flow_SOURCES} - DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/inviscid-flow-sw ) diff --git a/src/Examples/inviscid-flow-sw/CompressibleConservativeVariables.h b/src/Examples/inviscid-flow-sw/CompressibleConservativeVariables.h deleted file mode 100644 index 01e820686..000000000 --- a/src/Examples/inviscid-flow-sw/CompressibleConservativeVariables.h +++ /dev/null @@ -1,147 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -namespace TNL { - -template< typename Mesh > -class CompressibleConservativeVariables -{ - public: - typedef Mesh MeshType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; - - CompressibleConservativeVariables(){}; - - CompressibleConservativeVariables( const MeshPointer& meshPointer ) - : density( meshPointer ), - momentum( meshPointer ), - //pressure( meshPointer ), - energy( meshPointer ){}; - - void setMesh( const MeshPointer& meshPointer ) - { - this->density->setMesh( meshPointer ); - this->momentum->setMesh( meshPointer ); - //this->pressure.setMesh( meshPointer ); - this->energy->setMesh( meshPointer ); - } - - template< typename Vector > - void bind( const MeshPointer& meshPointer, - const Vector& data, - IndexType offset = 0 ) - { - IndexType currentOffset( offset ); - this->density->bind( meshPointer, data, currentOffset ); - currentOffset += this->density->getDofs( meshPointer ); - for( IndexType i = 0; i < Dimensions; i++ ) - { - ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); - currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); - } - this->energy->bind( meshPointer, data, currentOffset ); - } - - IndexType getDofs( const MeshPointer& meshPointer ) const - { - return this->density->getDofs( meshPointer ) + - this->momentum->getDofs( meshPointer ) + - this->energy->getDofs( meshPointer ); - } - - MeshFunctionPointer& getDensity() - { - return this->density; - } - - const MeshFunctionPointer& getDensity() const - { - return this->density; - } - - void setDensity( MeshFunctionPointer& density ) - { - this->density = density; - } - - MomentumFieldPointer& getMomentum() - { - return this->momentum; - } - - const MomentumFieldPointer& getMomentum() const - { - return this->momentum; - } - - void setMomentum( MomentumFieldPointer& momentum ) - { - this->momentum = momentum; - } - - /*MeshFunctionPointer& getPressure() - { - return this->pressure; - } - - const MeshFunctionPointer& getPressure() const - { - return this->pressure; - } - - void setPressure( MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }*/ - - MeshFunctionPointer& getEnergy() - { - return this->energy; - } - - const MeshFunctionPointer& getEnergy() const - { - return this->energy; - } - - void setEnergy( MeshFunctionPointer& energy ) - { - this->energy = energy; - } - - void getVelocityField( VelocityFieldType& velocityField ) - { - - } - - protected: - - MeshFunctionPointer density; - MomentumFieldPointer momentum; - MeshFunctionPointer energy; - -}; - -} // namespace TN diff --git a/src/Examples/inviscid-flow-sw/LaxFridrichs.h b/src/Examples/inviscid-flow-sw/LaxFridrichs.h deleted file mode 100644 index c56d20aed..000000000 --- a/src/Examples/inviscid-flow-sw/LaxFridrichs.h +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - LaxFridrichs.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichs -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef LaxFridrichsContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); - } - - LaxFridrichs() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); - this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); - - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-sw/LaxFridrichsContinuity.h b/src/Examples/inviscid-flow-sw/LaxFridrichsContinuity.h deleted file mode 100644 index 82747cd18..000000000 --- a/src/Examples/inviscid-flow-sw/LaxFridrichsContinuity.h +++ /dev/null @@ -1,288 +0,0 @@ -/*************************************************************************** - LaxFridrichsContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsContinuityBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - RealType artificialViscosity; -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) - - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse - + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-sw/LaxFridrichsEnergy.h b/src/Examples/inviscid-flow-sw/LaxFridrichsEnergy.h deleted file mode 100644 index 03019ed23..000000000 --- a/src/Examples/inviscid-flow-sw/LaxFridrichsEnergy.h +++ /dev/null @@ -1,309 +0,0 @@ -/*************************************************************************** - LaxFridrichsEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east - - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse; - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse - + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) - -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumBase.h b/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumBase.h deleted file mode 100644 index cc2561748..000000000 --- a/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumBase.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsMomentumBase() - : artificialViscosity( 1.0 ){}; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumX.h b/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumX.h deleted file mode 100644 index 63def12d3..000000000 --- a/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumX.h +++ /dev/null @@ -1,276 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - //const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - //const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - //const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - //const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_u[ up ] * velocity_z_up ) - - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumY.h b/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumY.h deleted file mode 100644 index 8ce42282d..000000000 --- a/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumY.h +++ /dev/null @@ -1,260 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse - + ( ( rho_v[ up ] * velocity_z_up ) - - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumZ.h b/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumZ.h deleted file mode 100644 index a67e862ce..000000000 --- a/src/Examples/inviscid-flow-sw/LaxFridrichsMomentumZ.h +++ /dev/null @@ -1,240 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) - -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) - - ( rho_w[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_w[ north ] * velocity_y_north ) - - ( rho_w[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) - - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-sw/PhysicalVariablesGetter.h b/src/Examples/inviscid-flow-sw/PhysicalVariablesGetter.h deleted file mode 100644 index d7eeb7618..000000000 --- a/src/Examples/inviscid-flow-sw/PhysicalVariablesGetter.h +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { - -template< typename Mesh > -class PhysicalVariablesGetter -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - VelocityGetter( MeshFunctionPointer density, - MeshFunctionPointer momentum ) - : density( density ), momentum( momentum ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) - return 0; - else - return momentum.template getData< DeviceType >()( meshEntity ) / - density.template getData< DeviceType >()( meshEntity ); - } - - protected: - const MeshFunctionPointer density, momentum; - }; - - class PressureGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - PressureGetter( MeshFunctionPointer density, - MeshFunctionPointer energy, - VelocityFieldPointer momentum, - const RealType& gamma ) - : density( density ), energy( energy ), momentum( momentum ), gamma( gamma ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - const RealType e = energy.template getData< DeviceType >()( meshEntity ); - const RealType rho = density.template getData< DeviceType >()( meshEntity ); - const RealType momentumNorm = lpNorm( momentum.template getData< DeviceType >().getVector( meshEntity ), 2.0 ); - if( rho == 0.0 ) - return 0; - else - return ( gamma - 1.0 ) * ( e - 0.5 * momentumNorm * momentumNorm / rho ); - } - - protected: - const MeshFunctionPointer density, energy; - const VelocityFieldPointer momentum; - const RealType gamma; - }; - - - void getVelocity( const ConservativeVariablesPointer& conservativeVariables, - VelocityFieldPointer& velocity ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; - for( int i = 0; i < Dimensions; i++ ) - { - Pointers::SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), - ( *conservativeVariables->getMomentum() )[ i ] ); - evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); - } - } - - void getPressure( const ConservativeVariablesPointer& conservativeVariables, - const RealType& gamma, - MeshFunctionPointer& pressure ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; - Pointers::SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), - conservativeVariables->getEnergy(), - conservativeVariables->getMomentum(), - gamma ); - evaluator.evaluate( pressure, pressureGetter ); - } - -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-sw/RiemannProblemInitialCondition.h b/src/Examples/inviscid-flow-sw/RiemannProblemInitialCondition.h deleted file mode 100644 index b8e53d601..000000000 --- a/src/Examples/inviscid-flow-sw/RiemannProblemInitialCondition.h +++ /dev/null @@ -1,1417 +0,0 @@ -/*************************************************************************** - RiemannProblemInitialCondition.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -template -class RiemannProblemInitialConditionSetter -{ - -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 1,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 2,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template< typename Mesh > -class RiemannProblemInitialCondition -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; - - RiemannProblemInitialCondition() - : discontinuityPlacement( 0.5 ), - leftDensity( 1.0 ), rightDensity( 1.0 ), - leftVelocity( -2.0 ), rightVelocity( 2.0 ), - leftPressure( 0.4 ), rightPressure( 0.4 ), - gamma( 1.67 ){} - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "discontinuity-placement-0", "x-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-1", "y-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-2", "z-coordinate of the discontinuity placement.", 0.5 ); -/* - config.addEntry< double >( prefix + "left-density", "Density on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-density", "Density on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-velocity-0", "x-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-1", "y-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-2", "z-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-velocity-0", "x-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-1", "y-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-2", "z-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-pressure", "Pressure on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-pressure", "Pressure on the right side of the discontinuity.", 0.0 ); -*/ - config.addEntry< double >( prefix + "NWU-density", "This sets a value of northwest up density.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-0", "This sets a value of northwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-1", "This sets a value of northwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-2", "This sets a value of northwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-pressure", "This sets a value of northwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWU-density", "This sets a value of southwest up density.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-0", "This sets a value of southwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-1", "This sets a value of southwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-2", "This sets a value of southwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-pressure", "This sets a value of southwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NWD-density", "This sets a value of northwest down density.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-0", "This sets a value of northwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-1", "This sets a value of northwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-2", "This sets a value of northwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-pressure", "This sets a value of northwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWD-density", "This sets a value of southwest down density.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-0", "This sets a value of southwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-1", "This sets a value of southwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-2", "This sets a value of southwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-pressure", "This sets a value of southwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "NEU-density", "This sets a value of northeast up density.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-0", "This sets a value of northeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-1", "This sets a value of northeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-2", "This sets a value of northeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-pressure", "This sets a value of northeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SEU-density", "This sets a value of southeast up density.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-0", "This sets a value of southeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-1", "This sets a value of southeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-2", "This sets a value of southeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-pressure", "This sets a value of southeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NED-density", "This sets a value of northeast down density.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-0", "This sets a value of northeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-1", "This sets a value of northeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-2", "This sets a value of northeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-pressure", "This sets a value of northeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SED-density", "This sets a value of southeast down density.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-0", "This sets a value of southeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-1", "This sets a value of southeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-2", "This sets a value of southeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-pressure", "This sets a value of southeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "gamma", "Gamma in the ideal gas state equation.", 1.4 ); - - config.addEntry< String >( prefix + "initial", " One of predefined initial condition.", "none"); - config.addEntryEnum< String >( "none" ); - config.addEntryEnum< String >( "1D_2" ); - config.addEntryEnum< String >( "1D_3a" ); - config.addEntryEnum< String >( "1D_4" ); - config.addEntryEnum< String >( "1D_5" ); - config.addEntryEnum< String >( "1D_6" ); - config.addEntryEnum< String >( "1D_Noh" ); - config.addEntryEnum< String >( "1D_peak" ); - config.addEntryEnum< String >( "2D_3" ); - config.addEntryEnum< String >( "2D_4" ); - config.addEntryEnum< String >( "2D_6" ); - config.addEntryEnum< String >( "2D_12" ); - config.addEntryEnum< String >( "2D_15" ); - config.addEntryEnum< String >( "2D_17" ); - } - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - String initial = parameters.getParameter< String >( prefix + "initial" ); - if(initial == prefix + "none") - { - this->discontinuityPlacement.setup( parameters, prefix + "discontinuity-placement-" ); - this->gamma = parameters.getParameter< double >( prefix + "gamma" ); -/* - this->leftVelocity.setup( parameters, prefix + "left-velocity-" ); - this->rightVelocity.setup( parameters, prefix + "right-velocity-" ); - this->leftDensity = parameters.getParameter< double >( prefix + "left-density" ); - this->rightDensity = parameters.getParameter< double >( prefix + "right-density" ); - this->leftPressure = parameters.getParameter< double >( prefix + "left-pressure" ); - this->rightPressure = parameters.getParameter< double >( prefix + "right-pressure" ); -*/ - - this->NWUDensity = parameters.getParameter< RealType >( prefix + "NWU-density" ); - this->NWUVelocity.setup( parameters, prefix + "NWU-velocity-" ); - this->NWUPressure = parameters.getParameter< RealType >( prefix + "NWU-pressure" ); - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); - this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); - this->SWUPressure = parameters.getParameter< RealType >( prefix + "SWU-pressure" ); - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); - this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); - this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); - this->SWUEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); - this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); - this->SWDPressure = parameters.getParameter< RealType >( prefix + "SWD-pressure" ); - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); - this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); - this->NEUPressure = parameters.getParameter< RealType >( prefix + "NEU-pressure" ); - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); - this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); - this->SEUPressure = parameters.getParameter< RealType >( prefix + "SEU-pressure" ); - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); - this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); - this->NEDPressure = parameters.getParameter< RealType >( prefix + "NED-pressure" ); - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); - this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); - this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - - } - if(initial == prefix + "1D_2") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -2.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_3a") - predefinedInitialCondition( 1.4, 0.8, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1000.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.01, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -19.59745, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -19.59745, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_4") - predefinedInitialCondition( 1.666, 0.4, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 5.99924, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 5.99242, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 460.894, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 46.095, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 19.5975, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -6.19633, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_5") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_6") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.1, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.1, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.1, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_Noh") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.000001, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.000001, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_peak") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 0.12612, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 6.5915, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 782.929, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 3.15449, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 8.90470, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.26542, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_3") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5323, 0.138, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.5, 0.5323, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.3, 0.029, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.5, 0.3, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 1.206, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.206, 1.206, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.206, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_4") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5065, 1.1, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.1, 0.5065, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.35, 1.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.1, 0.35, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.8939, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.8939, 0.8939, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.8939, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_6") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 3.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.75, 0.5, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -0.75, 0.5, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.75, -0.5, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -0.75, -0.5, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_12") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 1.0, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.5313, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.4, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.7276, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.7276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_15") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5197, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5313, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.4, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - -0.6259, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.1, -0.3, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.1, -0.3, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.1, 0.4276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_17") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0625, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5197, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.2145, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, -0.4, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.1259, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - return true; - } - - void setDiscontinuityPlacement( const PointType& v ) - { - this->discontinuityPlacement = v; - } - - const PointType& getDiscontinuityPlasement() const - { - return this->discontinuityPlacement; - } - - void setLeftDensity( const RealType& leftDensity ) - { - this->leftDensity = leftDensity; - } - - const RealType& getLeftDensity() const - { - return this->leftDensity; - } - - void setRightDensity( const RealType& rightDensity ) - { - this->rightDensity = rightDensity; - } - - const RealType& getRightDensity() const - { - return this->rightDensity; - } - - void setLeftVelocity( const PointType& leftVelocity ) - { - this->leftVelocity = leftVelocity; - } - - const PointType& getLeftVelocity() const - { - return this->leftVelocity; - } - - void setRightVelocity( const RealType& rightVelocity ) - { - this->rightVelocity = rightVelocity; - } - - const PointType& getRightVelocity() const - { - return this->rightVelocity; - } - - void setLeftPressure( const RealType& leftPressure ) - { - this->leftPressure = leftPressure; - } - - const RealType& getLeftPressure() const - { - return this->leftPressure; - } - - void setRightPressure( const RealType& rightPressure ) - { - this->rightPressure = rightPressure; - } - - const RealType& getRightPressure() const - { - return this->rightPressure; - } - - - void predefinedInitialCondition( double preGamma, double preDiscX, double preDiscY, double preDiscZ, - double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ) - - { - this->discontinuityPlacement = PointLoad(preDiscX, preDiscY, preDiscZ); - this->gamma = preGamma; - - this->NWUDensity = preNWUDensity; - this->NWUVelocity = PointLoad(preNWUVelocityX, preNWUVelocityY, preNWUVelocityZ); - this->NWUPressure = preNWUPressure; - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = preNWUDensity; - this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); - this->SWUPressure = preSWUPressure; - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = preNWDDensity; - this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); - this->NWDPressure = preNWDPressure; - this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = preSWDDensity; - this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); - this->SWDPressure = preSWDPressure; - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = preNEUDensity; - this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); - this->NEUPressure = preNEUPressure; - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = preSEUDensity; - this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); - this->SEUPressure = preSEUPressure; - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = preNEDDensity; - this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); - this->NEDPressure = preNEDPressure; - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = preSEDDensity; - this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); - this->SEDPressure = preSEDPressure; - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - - std::cout << this->SEDEnergy; - std::cout << this->SWDEnergy; - - } - - PointType PointLoad( RealType ValueX, RealType ValueY, RealType ValueZ) - { - PointType point; - switch (Dimensions) - { - case 1: point[ 0 ] = ValueX; - break; - case 2: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - break; - case 3: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - point[ 2 ] = ValueZ; - break; - } - return point; - } - - RealType Energy( RealType Density, RealType Pressure, RealType gamma, PointType Velocity) - { - RealType energy; - switch (Dimensions) - { - case 1: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ))); - break; - case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); - break; - case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 3 ], 2 ))); - break; // druhou mocninu ps8t jako sou4in - } - return energy; - } - - void setInitialCondition( CompressibleConservativeVariables< MeshType >& conservativeVariables, - const PointType& center = PointType( 0.0 ) ) - { - RiemannProblemInitialConditionSetter* variablesSetter = new RiemannProblemInitialConditionSetter; - variablesSetter->setGamma(this->gamma); - variablesSetter->setDensity(this->NWUDensity, - this->NEUDensity, - this->SWUDensity, - this->SEUDensity, - this->NWDDensity, - this->NEDDensity, - this->SWDDensity, - this->SEDDensity); - variablesSetter->setMomentum(this->NWUMomentum, - this->NEUMomentum, - this->SWUMomentum, - this->SEUMomentum, - this->NWDMomentum, - this->NEDMomentum, - this->SWDMomentum, - this->SEDMomentum); - variablesSetter->setEnergy(this->NWUEnergy, - this->NEUEnergy, - this->SWUEnergy, - this->SEUEnergy, - this->NWDEnergy, - this->NEDEnergy, - this->SWDEnergy, - this->SEDEnergy); - variablesSetter->setDiscontinuity(this->discontinuityPlacement); - variablesSetter->placeDensity(conservativeVariables); - variablesSetter->placeMomentum(conservativeVariables); - variablesSetter->placeEnergy(conservativeVariables); - -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - -/* - typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; - typedef Operators::Analytic::Sign< Dimensions, RealType > SignType; - typedef Functions::OperatorFunction< SignType, VectorNormType > InitialConditionType; - typedef Pointers::SharedPointer< InitialConditionType, DeviceType > InitialConditionPointer; - - InitialConditionPointer initialCondition; - initialCondition->getFunction().setCenter( center ); - initialCondition->getFunction().setMaxNorm( true ); - initialCondition->getFunction().setRadius( discontinuityPlacement[ 0 ] ); - discontinuityPlacement *= 1.0 / discontinuityPlacement[ 0 ]; - for( int i = 1; i < Dimensions; i++ ) - discontinuityPlacement[ i ] = 1.0 / discontinuityPlacement[ i ]; - initialCondition->getFunction().setAnisotropy( discontinuityPlacement ); - initialCondition->getFunction().setMultiplicator( -1.0 ); - - Functions::MeshFunctionEvaluator< MeshFunctionType, InitialConditionType > evaluator; -*/ - /**** - * Density - */ -/* - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ -/* - initialCondition->getOperator().setPositiveValue( leftDensity ); - initialCondition->getOperator().setNegativeValue( rightDensity ); - evaluator.evaluate( conservativeVariables.getDensity(), initialCondition ); - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ - /**** - * Momentum - */ - -/* - for( int i = 0; i < Dimensions; i++ ) - { - initialCondition->getOperator().setPositiveValue( leftDensity * leftVelocity[ i ] ); - initialCondition->getOperator().setNegativeValue( rightDensity * rightVelocity[ i ] ); - evaluator.evaluate( conservativeVariables.getMomentum()[ i ], initialCondition ); - } -*/ - /**** - * Energy - */ -/* - conservativeVariables.getEnergy()->write( "energy-init", "gnuplot" ); -*/ -/* - const RealType leftKineticEnergy = leftVelocity.lpNorm( 2.0 ); - const RealType rightKineticEnergy = rightVelocity.lpNorm( 2.0 ); - const RealType leftEnergy = leftPressure / ( gamma - 1.0 ) + 0.5 * leftDensity * leftKineticEnergy * leftKineticEnergy; - const RealType rightEnergy = rightPressure / ( gamma - 1.0 ) + 0.5 * rightDensity * rightKineticEnergy * rightKineticEnergy; - initialCondition->getOperator().setPositiveValue( leftEnergy ); - initialCondition->getOperator().setNegativeValue( rightEnergy ); - evaluator.evaluate( (* conservativeVariables.getEnergy()), initialCondition ); - (* conservativeVariables.getEnergy())->write( "energy-init", "gnuplot" ); -*/ - } - - - protected: - - PointType discontinuityPlacement; - PointType NWUVelocity, NEUVelocity, SWUVelocity, SEUVelocity, NWDVelocity, NEDVelocity, SWDVelocity, SEDVelocity; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUPressure, NEUPressure, SWUPressure, SEUPressure, NWDPressure, NEDPressure, SWDPressure, SEDPressure; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType leftDensity, rightDensity; - PointType leftVelocity, rightVelocity; - RealType leftPressure, rightPressure; - - RealType gamma; // gamma in the ideal gas state equation -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-sw/Upwind.h b/src/Examples/inviscid-flow-sw/Upwind.h deleted file mode 100644 index 529e0aadf..000000000 --- a/src/Examples/inviscid-flow-sw/Upwind.h +++ /dev/null @@ -1,151 +0,0 @@ -/*************************************************************************** - Upwind.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "UpwindContinuity.h" -#include "UpwindEnergy.h" -#include "UpwindMomentumX.h" -#include "UpwindMomentumY.h" -#include "UpwindMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class Upwind -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef UpwindContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef UpwindMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef UpwindMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef UpwindMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef UpwindEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - } - - Upwind() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setGamma( const RealType& gamma ) - { - this->continuityOperatorPointer->setGamma( gamma ); - this->momentumXOperatorPointer->setGamma( gamma ); - this->momentumYOperatorPointer->setGamma( gamma ); - this->momentumZOperatorPointer->setGamma( gamma ); - this->energyOperatorPointer->setGamma( gamma ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->continuityOperatorPointer->setPressure( pressure ); - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setDensity( const MeshFunctionPointer& density ) - { - this->momentumXOperatorPointer->setDensity( density ); - this->momentumYOperatorPointer->setDensity( density ); - this->momentumZOperatorPointer->setDensity( density ); - this->energyOperatorPointer->setDensity( density ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-sw/UpwindEnergy.h b/src/Examples/inviscid-flow-sw/UpwindEnergy.h deleted file mode 100644 index 39f609006..000000000 --- a/src/Examples/inviscid-flow-sw/UpwindEnergy.h +++ /dev/null @@ -1,542 +0,0 @@ -/*************************************************************************** - UpwindEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - UpwindEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "UpwindEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; - - MeshFunctionPointer density; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - __cuda_callable__ - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - }; - - __cuda_callable__ - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) - ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-sw/UpwindMomentumBase.h b/src/Examples/inviscid-flow-sw/UpwindMomentumBase.h deleted file mode 100644 index be1333f81..000000000 --- a/src/Examples/inviscid-flow-sw/UpwindMomentumBase.h +++ /dev/null @@ -1,134 +0,0 @@ -/*************************************************************************** - UpwindMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - __cuda_callable__ - RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber + 1.0 ) * ( machNumber + 1.0 ) ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber + 1.0 ) * (machNumber + 1.0 ) ); - else - return density * velocity * velocity + pressure; - }; - - __cuda_callable__ - RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity * velocity + pressure; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber - 1.0 ) * (machNumber - 1.0 ) ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber - 1.0 ) * ( machNumber - 1.0 ) ); - else - return 0; - }; - - __cuda_callable__ - RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * velocity_other; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * velocity_other; - else - return density * velocity_main * velocity_other; - }; - - __cuda_callable__ - RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity_main * velocity_other; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * velocity_other; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * velocity_other; - else - return 0.0; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - MeshFunctionPointer density; - -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-sw/UpwindMomentumX.h b/src/Examples/inviscid-flow-sw/UpwindMomentumX.h deleted file mode 100644 index ed49dda94..000000000 --- a/src/Examples/inviscid-flow-sw/UpwindMomentumX.h +++ /dev/null @@ -1,342 +0,0 @@ -/*************************************************************************** - UpwindMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ); - - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-sw/UpwindMomentumY.h b/src/Examples/inviscid-flow-sw/UpwindMomentumY.h deleted file mode 100644 index c2126d43a..000000000 --- a/src/Examples/inviscid-flow-sw/UpwindMomentumY.h +++ /dev/null @@ -1,318 +0,0 @@ -/*************************************************************************** - UpwindMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-sw/UpwindMomentumZ.h b/src/Examples/inviscid-flow-sw/UpwindMomentumZ.h deleted file mode 100644 index 97339e804..000000000 --- a/src/Examples/inviscid-flow-sw/UpwindMomentumZ.h +++ /dev/null @@ -1,276 +0,0 @@ -/*************************************************************************** - UpwindMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) - - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) - ); - } - - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-sw/euler.cpp b/src/Examples/inviscid-flow-sw/euler.cpp deleted file mode 100644 index 4d76005cb..000000000 --- a/src/Examples/inviscid-flow-sw/euler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "euler.h" diff --git a/src/Examples/inviscid-flow-sw/euler.cu b/src/Examples/inviscid-flow-sw/euler.cu deleted file mode 100644 index 4d76005cb..000000000 --- a/src/Examples/inviscid-flow-sw/euler.cu +++ /dev/null @@ -1 +0,0 @@ -#include "euler.h" diff --git a/src/Examples/inviscid-flow-sw/euler.h b/src/Examples/inviscid-flow-sw/euler.h deleted file mode 100644 index 75279e605..000000000 --- a/src/Examples/inviscid-flow-sw/euler.h +++ /dev/null @@ -1,116 +0,0 @@ -#include -#include -#include -#include -#include -#include "eulerProblem.h" -#include "Upwind.h" -#include "eulerRhs.h" -#include "eulerBuildConfigTag.h" - -#include "RiemannProblemInitialCondition.h" - -using namespace TNL; - -typedef eulerBuildConfigTag BuildConfig; - -/**** - * Uncomment the following (and comment the previous line) for the complete build. - * This will include support for all floating point precisions, all indexing types - * and more solvers. You may then choose between them from the command line. - * The compile time may, however, take tens of minutes or even several hours, - * especially if CUDA is enabled. Use this, if you want, only for the final build, - * not in the development phase. - */ -//typedef tnlDefaultConfigTag BuildConfig; - -template< typename ConfigTag >class eulerConfig -{ - public: - static void configSetup( Config::ConfigDescription & config ) - { - config.addDelimiter( "Inviscid flow settings:" ); - config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "dirichlet"); - config.addEntryEnum< String >( "dirichlet" ); - config.addEntryEnum< String >( "neumann" ); - config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); - typedef Meshes::Grid< 3 > Mesh; - RiemannProblemInitialCondition< Mesh >::configSetup( config ); - - /**** - * Add definition of your solver command line arguments. - */ - - } -}; - -template< typename Real, - typename Device, - typename Index, - typename MeshType, - typename ConfigTag, - typename SolverStarter, - typename Communicator > -class eulerSetter -{ - public: - - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - static bool run( const Config::ParameterContainer & parameters ) - { - enum { Dimension = MeshType::getMeshDimension() }; - typedef Upwind< MeshType, Real, Index > ApproximateOperator; - typedef eulerRhs< MeshType, Real > RightHandSide; - typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; - - /**** - * Resolve the template arguments of your solver here. - * The following code is for the Dirichlet and the Neumann boundary conditions. - * Both can be constant or defined as descrete values of Vector. - */ - String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); - if( parameters.checkParameter( "boundary-conditions-constant" ) ) - { - typedef Functions::Analytic::Constant< Dimension, Real > Constant; - if( boundaryConditionsType == "dirichlet" ) - { - typedef Operators::DirichletBoundaryConditions< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - typedef Operators::NeumannBoundaryConditions< MeshType, Constant, Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - typedef Functions::MeshFunction< MeshType > MeshFunction; - if( boundaryConditionsType == "dirichlet" ) - { - typedef Operators::DirichletBoundaryConditions< MeshType, MeshFunction, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "neumann" ) - { - typedef Operators::NeumannBoundaryConditions< MeshType, MeshFunction, Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - - return true;} - -}; - -int main( int argc, char* argv[] ) -{ - Solvers::Solver< eulerSetter, eulerConfig, BuildConfig > solver; - if( ! solver. run( argc, argv ) ) - return EXIT_FAILURE; - return EXIT_SUCCESS; -} diff --git a/src/Examples/inviscid-flow-sw/eulerBuildConfigTag.h b/src/Examples/inviscid-flow-sw/eulerBuildConfigTag.h deleted file mode 100644 index da0612462..000000000 --- a/src/Examples/inviscid-flow-sw/eulerBuildConfigTag.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -#include - -namespace TNL { - -class eulerBuildConfigTag{}; - -namespace Solvers { - -/**** - * Turn off support for float and long double. - */ -template<> struct ConfigTagReal< eulerBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct ConfigTagReal< eulerBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct ConfigTagIndex< eulerBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct ConfigTagIndex< eulerBuildConfigTag, long int >{ enum { enabled = false }; }; - -/**** - * Please, chose your preferred time discretisation here. - */ -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; - -/**** - * Only the Runge-Kutta-Merson solver is enabled by default. - */ -template<> struct ConfigTagExplicitSolver< eulerBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; - -} // namespace Solvers - -namespace Meshes { -namespace BuildConfigTags { - -template< int Dimensions > struct GridDimensionTag< eulerBuildConfigTag, Dimensions >{ enum { enabled = ( Dimensions == 1 ) }; }; - -/**** - * Turn off support for float and long double. - */ -template<> struct GridRealTag< eulerBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct GridRealTag< eulerBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct GridIndexTag< eulerBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct GridIndexTag< eulerBuildConfigTag, long int >{ enum { enabled = false }; }; - -} // namespace BuildConfigTags -} // namespace Meshes -} // namespace TNL diff --git a/src/Examples/inviscid-flow-sw/eulerProblem.h b/src/Examples/inviscid-flow-sw/eulerProblem.h deleted file mode 100644 index 02b99cd83..000000000 --- a/src/Examples/inviscid-flow-sw/eulerProblem.h +++ /dev/null @@ -1,126 +0,0 @@ -/*************************************************************************** - eulerProblem.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include "CompressibleConservativeVariables.h" - - -using namespace TNL::Problems; - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -class eulerProblem: - public PDEProblem< Mesh, - Communicator, - typename InviscidOperators::RealType, - typename Mesh::DeviceType, - typename InviscidOperators::IndexType > -{ - public: - - typedef typename InviscidOperators::RealType RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef typename InviscidOperators::IndexType IndexType; - typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; - - typedef Communicator CommunicatorType; - - using typename BaseType::MeshType; - using typename BaseType::MeshPointer; - using typename BaseType::DofVectorType; - using typename BaseType::DofVectorPointer; - static const int Dimensions = Mesh::getMeshDimension(); - - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; - typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; - typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; - using CommunicatorType = Communicator; - - static String getType(); - - String getPrologHeader() const; - - void writeProlog( Logger& logger, - const Config::ParameterContainer& parameters ) const; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ); - - bool setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ); - - template< typename Matrix > - bool setupLinearSystem( Matrix& matrix ); - - bool makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ); - - IndexType getDofs() const; - - void bindDofs( DofVectorPointer& dofs ); - - void getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ); - - void applyBoundaryConditions( const RealType& time, - DofVectorPointer& dofs ) - { - throw Exceptions::NotImplementedError( "TODO: implement BC ... see HeatEquationProblem" ); - } - - template< typename Matrix > - void assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs, - Matrix& matrix, - DofVectorPointer& rightHandSide ); - - bool postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ); - - protected: - - InviscidOperatorsPointer inviscidOperatorsPointer; - - BoundaryConditionPointer boundaryConditionPointer; - RightHandSidePointer rightHandSidePointer; - - ConservativeVariablesPointer conservativeVariables, - conservativeVariablesRHS; - - VelocityFieldPointer velocity; - MeshFunctionPointer pressure; - - RealType gamma; -}; - -} // namespace TNL - -#include "eulerProblem_impl.h" - diff --git a/src/Examples/inviscid-flow-sw/eulerProblem_impl.h b/src/Examples/inviscid-flow-sw/eulerProblem_impl.h deleted file mode 100644 index 349fe7e19..000000000 --- a/src/Examples/inviscid-flow-sw/eulerProblem_impl.h +++ /dev/null @@ -1,408 +0,0 @@ -/*************************************************************************** - eulerProblem_impl.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -#include "RiemannProblemInitialCondition.h" -#include "CompressibleConservativeVariables.h" -#include "PhysicalVariablesGetter.h" -#include "eulerProblem.h" - -#include "UpwindContinuity.h" -#include "UpwindEnergy.h" -#include "UpwindMomentumX.h" -#include "UpwindMomentumY.h" -#include "UpwindMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getType() -{ - return String( "eulerProblem< " ) + Mesh :: getTypeStatic() + " >"; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getPrologHeader() const -{ - return String( "Inviscid flow solver" ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, -writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const -{ - /**** - * Add data you want to have in the computation report (log) as follows: - * logger.writeParameter< double >( "Parameter description", parameter ); - */ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -setup( const Config::ParameterContainer& parameters, - const String& prefix ) -{ - if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || - ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || - ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) - return false; - this->gamma = parameters.getParameter< double >( "gamma" ); - velocity->setMesh( this->getMesh() ); - pressure->setMesh( this->getMesh() ); - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -{ - /**** - * Return number of DOFs (degrees of freedom) i.e. number - * of unknowns to be resolved by the main solver. - */ - return this->conservativeVariables->getDofs( this->getMesh() ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -typename eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >::IndexType -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getDofs( ) const -bindDofs( DofVectorPointer& dofVector ) -{ - this->conservativeVariables->bind( this->getMesh(), dofVector ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, -setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ) -{ - CompressibleConservativeVariables< MeshType > conservativeVariables; - conservativeVariables.bind( this->getMesh(), dofs ); - const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); - if( initialConditionType == "riemann-problem" ) - { - RiemannProblemInitialCondition< MeshType > initialCondition; - if( ! initialCondition.setup( parameters ) ) - return false; - initialCondition.setInitialCondition( conservativeVariables ); - return true; - } - std::cerr << "Unknown initial condition " << initialConditionType << std::endl; - return false; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -setupLinearSystem( Matrix& matrix ) -{ -/* const IndexType dofs = this->getDofs(); - typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; - CompressedRowLengthsVectorType rowLengths; - if( ! rowLengths.setSize( dofs ) ) - return false; - MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; - matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, - differentialOperator, - boundaryCondition, - rowLengths ); - matrix.setDimensions( dofs, dofs ); - if( ! matrix.setCompressedRowLengths( rowLengths ) ) - return false;*/ - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ) -{ - std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; - - this->bindDofs( dofs ); - PhysicalVariablesGetter< MeshType > physicalVariablesGetter; - physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - FileName fileName; - fileName.setExtension( "tnl" ); - fileName.setIndex( step ); - fileName.setFileNameBase( "density-" ); - this->conservativeVariables->getDensity()->save( fileName.getFileName() ); - - fileName.setFileNameBase( "velocity-" ); - this->velocity->save( fileName.getFileName() ); - - fileName.setFileNameBase( "pressure-" ); - this->pressure->save( fileName.getFileName() ); - - fileName.setFileNameBase( "energy-" ); - this->conservativeVariables->getEnergy()->save( fileName.getFileName() ); - - fileName.setFileNameBase( "momentum-" ); - this->conservativeVariables->getMomentum()->save( fileName.getFileName() ); - - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > - template< typename Matrix > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ) -{ - typedef typename MeshType::Cell Cell; - const MeshPointer& mesh = this->getMesh(); - - /**** - * Bind DOFs - */ - this->conservativeVariables->bind( this->getMesh(), _u ); - this->conservativeVariablesRHS->bind( this->getMesh(), _fu ); - this->velocity->setMesh( this->getMesh() ); - this->pressure->setMesh( this->getMesh() ); - - /**** - * Resolve the physical variables - */ - PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; - physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - /**** - * Set-up operators - */ - typedef typename InviscidOperators::ContinuityOperatorType ContinuityOperatorType; - typedef typename InviscidOperators::MomentumXOperatorType MomentumXOperatorType; - typedef typename InviscidOperators::MomentumYOperatorType MomentumYOperatorType; - typedef typename InviscidOperators::MomentumZOperatorType MomentumZOperatorType; - typedef typename InviscidOperators::EnergyOperatorType EnergyOperatorType; - - this->inviscidOperatorsPointer->setTau( tau ); - this->inviscidOperatorsPointer->setVelocity( this->velocity ); - this->inviscidOperatorsPointer->setPressure( this->pressure ); - this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); - this->inviscidOperatorsPointer->setGamma( this->gamma ); - -// this->pressure->write( "pressure2", "gnuplot" ); -// getchar(); - /**** - * Continuity equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, ContinuityOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterContinuity; - explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); - explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); - typename Communicator, - typename InviscidOperators > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: - - /**** - * Momentum equations - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumXOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumX; - explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); - explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); - typename Communicator, - typename InviscidOperators > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: - - if( Dimensions > 1 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumYOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumY; - explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); - explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); - } - - if( Dimensions > 2 ) { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumZ; - explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); - explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); - } - - - /**** - * Energy equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, EnergyOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterEnergy; - explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); - explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - this->conservativeVariables->getDensity(), - this->conservativeVariablesRHS->getDensity() ); - -/* this->pressure->write( "pressure3", "gnuplot" ); - getchar(); - this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); - this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); - this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); - getchar();*/ - -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); -assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - Matrix& matrix, - DofVectorPointer& b ) -{ -/* LinearSystemAssembler< Mesh, - MeshFunctionType, - InviscidOperators, - BoundaryCondition, - RightHandSide, - BackwardTimeDiscretisation, - Matrix, - DofVectorType > systemAssembler; - - MeshFunction< Mesh > u( mesh, _u ); - systemAssembler.template assembly< typename Mesh::Cell >( time, - tau, - mesh, - this->differentialOperator, - this->boundaryCondition, - this->rightHandSide, - u, - matrix, - b );*/ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); -postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ) -{ - /* - typedef typename MeshType::Cell Cell; - int count = mesh->template getEntitiesCount< Cell >()/4; - //bind _u - this->_uRho.bind( *dofs, 0, count); - this->_uRhoVelocityX.bind( *dofs, count, count); - this->_uRhoVelocityY.bind( *dofs, 2 * count, count); - this->_uEnergy.bind( *dofs, 3 * count, count); - - MeshFunctionType velocity( mesh, this->velocity ); - MeshFunctionType velocityX( mesh, this->velocityX ); - MeshFunctionType velocityY( mesh, this->velocityY ); - MeshFunctionType pressure( mesh, this->pressure ); - MeshFunctionType uRho( mesh, _uRho ); - MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); - MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); - MeshFunctionType uEnergy( mesh, _uEnergy ); - //Generating differential operators - Velocity euler2DVelocity; - VelocityX euler2DVelocityX; - VelocityY euler2DVelocityY; - Pressure euler2DPressure; - - //velocityX - euler2DVelocityX.setRhoVelX(uRhoVelocityX); - euler2DVelocityX.setRho(uRho); -// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; -// velocityX = OFVelocityX; - - //velocityY - euler2DVelocityY.setRhoVelY(uRhoVelocityY); - euler2DVelocityY.setRho(uRho); -// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; -// velocityY = OFVelocityY; - - //velocity - euler2DVelocity.setVelX(velocityX); - euler2DVelocity.setVelY(velocityY); -// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; -// velocity = OFVelocity; - - //pressure - euler2DPressure.setGamma(gamma); - euler2DPressure.setVelocity(velocity); - euler2DPressure.setEnergy(uEnergy); - euler2DPressure.setRho(uRho); -// OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure; -// pressure = OFPressure; - */ - return true; -} - -} // namespace TNL - - explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); diff --git a/src/Examples/inviscid-flow-sw/eulerRhs.h b/src/Examples/inviscid-flow-sw/eulerRhs.h deleted file mode 100644 index 51d4e0243..000000000 --- a/src/Examples/inviscid-flow-sw/eulerRhs.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef eulerRHS_H_ -#define eulerRHS_H_ - -#include - -namespace TNL { - -template< typename Mesh, typename Real >class eulerRhs - : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > - { - public: - - typedef Mesh MeshType; - typedef Real RealType; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; - } - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const Real& time = 0.0 ) const - { - typedef typename MeshEntity::MeshType::PointType PointType; - PointType v = entity.getCenter(); - return 0.0; - } -}; - -} //namespace TNL - -#endif /* eulerRHS_H_ */ diff --git a/src/Examples/inviscid-flow-sw/run-euler-sw b/src/Examples/inviscid-flow-sw/run-euler-sw deleted file mode 100644 index 9ebf9cbb5..000000000 --- a/src/Examples/inviscid-flow-sw/run-euler-sw +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 2 \ - --origin-x 0.0 \ - --origin-y 0.0 \ - --proportions-x 1.0 \ - --proportions-y 1.0 \ - --size-x 100 \ - --size-y 100 - -tnl-init --test-function sin-wave \ - --output-file init.tnl -tnl-euler-2d --initial-condition riemann-problem \ - --discontinuity-placement-0 0.3 \ - --discontinuity-placement-1 0.3 \ - --discontinuity-placement-2 0.3 \ - --time-discretisation explicit \ - --boundary-conditions-type neumann \ - --boundary-conditions-constant 0 \ - --discrete-solver euler \ - --time-step 0.0001 \ - --snapshot-period 0.01 \ - --final-time 1.0 - -tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/inviscid-flow-vl/CMakeLists.txt b/src/Examples/inviscid-flow-vl/CMakeLists.txt deleted file mode 100644 index d0111a5a1..000000000 --- a/src/Examples/inviscid-flow-vl/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -set( tnl_inviscid_flow_vl_HEADERS - CompressibleConservativeVariables.h ) - -set( tnl_inviscid_flow_vl_SOURCES - euler.cpp - euler.cu ) - -IF( BUILD_CUDA ) - CUDA_ADD_EXECUTABLE(tnl-euler-vl euler.cu) -ELSE( BUILD_CUDA ) - ADD_EXECUTABLE(tnl-euler-vl euler.cpp) -ENDIF( BUILD_CUDA ) - - -INSTALL( TARGETS tnl-euler-vl - RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) - -INSTALL( FILES run-euler-vl - ${tnl_inviscid_flow_SOURCES} - DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/inviscid-flow-vl ) diff --git a/src/Examples/inviscid-flow-vl/LaxFridrichs.h b/src/Examples/inviscid-flow-vl/LaxFridrichs.h deleted file mode 100644 index c56d20aed..000000000 --- a/src/Examples/inviscid-flow-vl/LaxFridrichs.h +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - LaxFridrichs.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichs -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef LaxFridrichsContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); - } - - LaxFridrichs() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); - this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); - - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-vl/LaxFridrichsContinuity.h b/src/Examples/inviscid-flow-vl/LaxFridrichsContinuity.h deleted file mode 100644 index 82747cd18..000000000 --- a/src/Examples/inviscid-flow-vl/LaxFridrichsContinuity.h +++ /dev/null @@ -1,288 +0,0 @@ -/*************************************************************************** - LaxFridrichsContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsContinuityBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - RealType artificialViscosity; -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) - - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse - + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-vl/LaxFridrichsEnergy.h b/src/Examples/inviscid-flow-vl/LaxFridrichsEnergy.h deleted file mode 100644 index 03019ed23..000000000 --- a/src/Examples/inviscid-flow-vl/LaxFridrichsEnergy.h +++ /dev/null @@ -1,309 +0,0 @@ -/*************************************************************************** - LaxFridrichsEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east - - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse; - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse - + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) - -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumBase.h b/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumBase.h deleted file mode 100644 index cc2561748..000000000 --- a/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumBase.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsMomentumBase() - : artificialViscosity( 1.0 ){}; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumX.h b/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumX.h deleted file mode 100644 index 63def12d3..000000000 --- a/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumX.h +++ /dev/null @@ -1,276 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - //const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - //const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - //const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - //const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_u[ up ] * velocity_z_up ) - - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumY.h b/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumY.h deleted file mode 100644 index 8ce42282d..000000000 --- a/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumY.h +++ /dev/null @@ -1,260 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse - + ( ( rho_v[ up ] * velocity_z_up ) - - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumZ.h b/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumZ.h deleted file mode 100644 index a67e862ce..000000000 --- a/src/Examples/inviscid-flow-vl/LaxFridrichsMomentumZ.h +++ /dev/null @@ -1,240 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) - -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) - - ( rho_w[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_w[ north ] * velocity_y_north ) - - ( rho_w[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) - - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-vl/RiemannProblemInitialCondition.h b/src/Examples/inviscid-flow-vl/RiemannProblemInitialCondition.h deleted file mode 100644 index b8e53d601..000000000 --- a/src/Examples/inviscid-flow-vl/RiemannProblemInitialCondition.h +++ /dev/null @@ -1,1417 +0,0 @@ -/*************************************************************************** - RiemannProblemInitialCondition.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -template -class RiemannProblemInitialConditionSetter -{ - -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 1,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 2,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template< typename Mesh > -class RiemannProblemInitialCondition -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; - - RiemannProblemInitialCondition() - : discontinuityPlacement( 0.5 ), - leftDensity( 1.0 ), rightDensity( 1.0 ), - leftVelocity( -2.0 ), rightVelocity( 2.0 ), - leftPressure( 0.4 ), rightPressure( 0.4 ), - gamma( 1.67 ){} - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "discontinuity-placement-0", "x-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-1", "y-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-2", "z-coordinate of the discontinuity placement.", 0.5 ); -/* - config.addEntry< double >( prefix + "left-density", "Density on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-density", "Density on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-velocity-0", "x-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-1", "y-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-2", "z-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-velocity-0", "x-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-1", "y-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-2", "z-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-pressure", "Pressure on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-pressure", "Pressure on the right side of the discontinuity.", 0.0 ); -*/ - config.addEntry< double >( prefix + "NWU-density", "This sets a value of northwest up density.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-0", "This sets a value of northwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-1", "This sets a value of northwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-2", "This sets a value of northwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-pressure", "This sets a value of northwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWU-density", "This sets a value of southwest up density.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-0", "This sets a value of southwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-1", "This sets a value of southwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-2", "This sets a value of southwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-pressure", "This sets a value of southwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NWD-density", "This sets a value of northwest down density.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-0", "This sets a value of northwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-1", "This sets a value of northwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-2", "This sets a value of northwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-pressure", "This sets a value of northwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWD-density", "This sets a value of southwest down density.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-0", "This sets a value of southwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-1", "This sets a value of southwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-2", "This sets a value of southwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-pressure", "This sets a value of southwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "NEU-density", "This sets a value of northeast up density.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-0", "This sets a value of northeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-1", "This sets a value of northeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-2", "This sets a value of northeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-pressure", "This sets a value of northeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SEU-density", "This sets a value of southeast up density.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-0", "This sets a value of southeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-1", "This sets a value of southeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-2", "This sets a value of southeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-pressure", "This sets a value of southeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NED-density", "This sets a value of northeast down density.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-0", "This sets a value of northeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-1", "This sets a value of northeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-2", "This sets a value of northeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-pressure", "This sets a value of northeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SED-density", "This sets a value of southeast down density.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-0", "This sets a value of southeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-1", "This sets a value of southeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-2", "This sets a value of southeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-pressure", "This sets a value of southeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "gamma", "Gamma in the ideal gas state equation.", 1.4 ); - - config.addEntry< String >( prefix + "initial", " One of predefined initial condition.", "none"); - config.addEntryEnum< String >( "none" ); - config.addEntryEnum< String >( "1D_2" ); - config.addEntryEnum< String >( "1D_3a" ); - config.addEntryEnum< String >( "1D_4" ); - config.addEntryEnum< String >( "1D_5" ); - config.addEntryEnum< String >( "1D_6" ); - config.addEntryEnum< String >( "1D_Noh" ); - config.addEntryEnum< String >( "1D_peak" ); - config.addEntryEnum< String >( "2D_3" ); - config.addEntryEnum< String >( "2D_4" ); - config.addEntryEnum< String >( "2D_6" ); - config.addEntryEnum< String >( "2D_12" ); - config.addEntryEnum< String >( "2D_15" ); - config.addEntryEnum< String >( "2D_17" ); - } - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - String initial = parameters.getParameter< String >( prefix + "initial" ); - if(initial == prefix + "none") - { - this->discontinuityPlacement.setup( parameters, prefix + "discontinuity-placement-" ); - this->gamma = parameters.getParameter< double >( prefix + "gamma" ); -/* - this->leftVelocity.setup( parameters, prefix + "left-velocity-" ); - this->rightVelocity.setup( parameters, prefix + "right-velocity-" ); - this->leftDensity = parameters.getParameter< double >( prefix + "left-density" ); - this->rightDensity = parameters.getParameter< double >( prefix + "right-density" ); - this->leftPressure = parameters.getParameter< double >( prefix + "left-pressure" ); - this->rightPressure = parameters.getParameter< double >( prefix + "right-pressure" ); -*/ - - this->NWUDensity = parameters.getParameter< RealType >( prefix + "NWU-density" ); - this->NWUVelocity.setup( parameters, prefix + "NWU-velocity-" ); - this->NWUPressure = parameters.getParameter< RealType >( prefix + "NWU-pressure" ); - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); - this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); - this->SWUPressure = parameters.getParameter< RealType >( prefix + "SWU-pressure" ); - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); - this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); - this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); - this->SWUEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); - this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); - this->SWDPressure = parameters.getParameter< RealType >( prefix + "SWD-pressure" ); - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); - this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); - this->NEUPressure = parameters.getParameter< RealType >( prefix + "NEU-pressure" ); - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); - this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); - this->SEUPressure = parameters.getParameter< RealType >( prefix + "SEU-pressure" ); - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); - this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); - this->NEDPressure = parameters.getParameter< RealType >( prefix + "NED-pressure" ); - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); - this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); - this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - - } - if(initial == prefix + "1D_2") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -2.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_3a") - predefinedInitialCondition( 1.4, 0.8, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1000.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.01, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -19.59745, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -19.59745, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_4") - predefinedInitialCondition( 1.666, 0.4, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 5.99924, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 5.99242, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 460.894, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 46.095, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 19.5975, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -6.19633, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_5") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_6") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.1, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.1, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.1, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_Noh") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.000001, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.000001, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_peak") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 0.12612, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 6.5915, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 782.929, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 3.15449, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 8.90470, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.26542, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_3") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5323, 0.138, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.5, 0.5323, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.3, 0.029, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.5, 0.3, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 1.206, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.206, 1.206, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.206, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_4") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5065, 1.1, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.1, 0.5065, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.35, 1.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.1, 0.35, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.8939, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.8939, 0.8939, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.8939, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_6") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 3.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.75, 0.5, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -0.75, 0.5, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.75, -0.5, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -0.75, -0.5, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_12") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 1.0, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.5313, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.4, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.7276, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.7276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_15") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5197, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5313, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.4, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - -0.6259, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.1, -0.3, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.1, -0.3, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.1, 0.4276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_17") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0625, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5197, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.2145, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, -0.4, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.1259, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - return true; - } - - void setDiscontinuityPlacement( const PointType& v ) - { - this->discontinuityPlacement = v; - } - - const PointType& getDiscontinuityPlasement() const - { - return this->discontinuityPlacement; - } - - void setLeftDensity( const RealType& leftDensity ) - { - this->leftDensity = leftDensity; - } - - const RealType& getLeftDensity() const - { - return this->leftDensity; - } - - void setRightDensity( const RealType& rightDensity ) - { - this->rightDensity = rightDensity; - } - - const RealType& getRightDensity() const - { - return this->rightDensity; - } - - void setLeftVelocity( const PointType& leftVelocity ) - { - this->leftVelocity = leftVelocity; - } - - const PointType& getLeftVelocity() const - { - return this->leftVelocity; - } - - void setRightVelocity( const RealType& rightVelocity ) - { - this->rightVelocity = rightVelocity; - } - - const PointType& getRightVelocity() const - { - return this->rightVelocity; - } - - void setLeftPressure( const RealType& leftPressure ) - { - this->leftPressure = leftPressure; - } - - const RealType& getLeftPressure() const - { - return this->leftPressure; - } - - void setRightPressure( const RealType& rightPressure ) - { - this->rightPressure = rightPressure; - } - - const RealType& getRightPressure() const - { - return this->rightPressure; - } - - - void predefinedInitialCondition( double preGamma, double preDiscX, double preDiscY, double preDiscZ, - double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ) - - { - this->discontinuityPlacement = PointLoad(preDiscX, preDiscY, preDiscZ); - this->gamma = preGamma; - - this->NWUDensity = preNWUDensity; - this->NWUVelocity = PointLoad(preNWUVelocityX, preNWUVelocityY, preNWUVelocityZ); - this->NWUPressure = preNWUPressure; - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = preNWUDensity; - this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); - this->SWUPressure = preSWUPressure; - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = preNWDDensity; - this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); - this->NWDPressure = preNWDPressure; - this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = preSWDDensity; - this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); - this->SWDPressure = preSWDPressure; - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = preNEUDensity; - this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); - this->NEUPressure = preNEUPressure; - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = preSEUDensity; - this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); - this->SEUPressure = preSEUPressure; - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = preNEDDensity; - this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); - this->NEDPressure = preNEDPressure; - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = preSEDDensity; - this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); - this->SEDPressure = preSEDPressure; - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - - std::cout << this->SEDEnergy; - std::cout << this->SWDEnergy; - - } - - PointType PointLoad( RealType ValueX, RealType ValueY, RealType ValueZ) - { - PointType point; - switch (Dimensions) - { - case 1: point[ 0 ] = ValueX; - break; - case 2: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - break; - case 3: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - point[ 2 ] = ValueZ; - break; - } - return point; - } - - RealType Energy( RealType Density, RealType Pressure, RealType gamma, PointType Velocity) - { - RealType energy; - switch (Dimensions) - { - case 1: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ))); - break; - case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); - break; - case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 3 ], 2 ))); - break; // druhou mocninu ps8t jako sou4in - } - return energy; - } - - void setInitialCondition( CompressibleConservativeVariables< MeshType >& conservativeVariables, - const PointType& center = PointType( 0.0 ) ) - { - RiemannProblemInitialConditionSetter* variablesSetter = new RiemannProblemInitialConditionSetter; - variablesSetter->setGamma(this->gamma); - variablesSetter->setDensity(this->NWUDensity, - this->NEUDensity, - this->SWUDensity, - this->SEUDensity, - this->NWDDensity, - this->NEDDensity, - this->SWDDensity, - this->SEDDensity); - variablesSetter->setMomentum(this->NWUMomentum, - this->NEUMomentum, - this->SWUMomentum, - this->SEUMomentum, - this->NWDMomentum, - this->NEDMomentum, - this->SWDMomentum, - this->SEDMomentum); - variablesSetter->setEnergy(this->NWUEnergy, - this->NEUEnergy, - this->SWUEnergy, - this->SEUEnergy, - this->NWDEnergy, - this->NEDEnergy, - this->SWDEnergy, - this->SEDEnergy); - variablesSetter->setDiscontinuity(this->discontinuityPlacement); - variablesSetter->placeDensity(conservativeVariables); - variablesSetter->placeMomentum(conservativeVariables); - variablesSetter->placeEnergy(conservativeVariables); - -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - -/* - typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; - typedef Operators::Analytic::Sign< Dimensions, RealType > SignType; - typedef Functions::OperatorFunction< SignType, VectorNormType > InitialConditionType; - typedef Pointers::SharedPointer< InitialConditionType, DeviceType > InitialConditionPointer; - - InitialConditionPointer initialCondition; - initialCondition->getFunction().setCenter( center ); - initialCondition->getFunction().setMaxNorm( true ); - initialCondition->getFunction().setRadius( discontinuityPlacement[ 0 ] ); - discontinuityPlacement *= 1.0 / discontinuityPlacement[ 0 ]; - for( int i = 1; i < Dimensions; i++ ) - discontinuityPlacement[ i ] = 1.0 / discontinuityPlacement[ i ]; - initialCondition->getFunction().setAnisotropy( discontinuityPlacement ); - initialCondition->getFunction().setMultiplicator( -1.0 ); - - Functions::MeshFunctionEvaluator< MeshFunctionType, InitialConditionType > evaluator; -*/ - /**** - * Density - */ -/* - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ -/* - initialCondition->getOperator().setPositiveValue( leftDensity ); - initialCondition->getOperator().setNegativeValue( rightDensity ); - evaluator.evaluate( conservativeVariables.getDensity(), initialCondition ); - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ - /**** - * Momentum - */ - -/* - for( int i = 0; i < Dimensions; i++ ) - { - initialCondition->getOperator().setPositiveValue( leftDensity * leftVelocity[ i ] ); - initialCondition->getOperator().setNegativeValue( rightDensity * rightVelocity[ i ] ); - evaluator.evaluate( conservativeVariables.getMomentum()[ i ], initialCondition ); - } -*/ - /**** - * Energy - */ -/* - conservativeVariables.getEnergy()->write( "energy-init", "gnuplot" ); -*/ -/* - const RealType leftKineticEnergy = leftVelocity.lpNorm( 2.0 ); - const RealType rightKineticEnergy = rightVelocity.lpNorm( 2.0 ); - const RealType leftEnergy = leftPressure / ( gamma - 1.0 ) + 0.5 * leftDensity * leftKineticEnergy * leftKineticEnergy; - const RealType rightEnergy = rightPressure / ( gamma - 1.0 ) + 0.5 * rightDensity * rightKineticEnergy * rightKineticEnergy; - initialCondition->getOperator().setPositiveValue( leftEnergy ); - initialCondition->getOperator().setNegativeValue( rightEnergy ); - evaluator.evaluate( (* conservativeVariables.getEnergy()), initialCondition ); - (* conservativeVariables.getEnergy())->write( "energy-init", "gnuplot" ); -*/ - } - - - protected: - - PointType discontinuityPlacement; - PointType NWUVelocity, NEUVelocity, SWUVelocity, SEUVelocity, NWDVelocity, NEDVelocity, SWDVelocity, SEDVelocity; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUPressure, NEUPressure, SWUPressure, SEUPressure, NWDPressure, NEDPressure, SWDPressure, SEDPressure; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType leftDensity, rightDensity; - PointType leftVelocity, rightVelocity; - RealType leftPressure, rightPressure; - - RealType gamma; // gamma in the ideal gas state equation -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-vl/Upwind.h b/src/Examples/inviscid-flow-vl/Upwind.h deleted file mode 100644 index 529e0aadf..000000000 --- a/src/Examples/inviscid-flow-vl/Upwind.h +++ /dev/null @@ -1,151 +0,0 @@ -/*************************************************************************** - Upwind.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "UpwindContinuity.h" -#include "UpwindEnergy.h" -#include "UpwindMomentumX.h" -#include "UpwindMomentumY.h" -#include "UpwindMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class Upwind -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef UpwindContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef UpwindMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef UpwindMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef UpwindMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef UpwindEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - } - - Upwind() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setGamma( const RealType& gamma ) - { - this->continuityOperatorPointer->setGamma( gamma ); - this->momentumXOperatorPointer->setGamma( gamma ); - this->momentumYOperatorPointer->setGamma( gamma ); - this->momentumZOperatorPointer->setGamma( gamma ); - this->energyOperatorPointer->setGamma( gamma ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->continuityOperatorPointer->setPressure( pressure ); - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setDensity( const MeshFunctionPointer& density ) - { - this->momentumXOperatorPointer->setDensity( density ); - this->momentumYOperatorPointer->setDensity( density ); - this->momentumZOperatorPointer->setDensity( density ); - this->energyOperatorPointer->setDensity( density ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-vl/UpwindContinuity.h b/src/Examples/inviscid-flow-vl/UpwindContinuity.h deleted file mode 100644 index 4a21cd502..000000000 --- a/src/Examples/inviscid-flow-vl/UpwindContinuity.h +++ /dev/null @@ -1,378 +0,0 @@ -/*************************************************************************** - UpwindContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - static String getType() - { - return String( "UpwindContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - __cuda_callable__ - RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); - else - return density * velocity; - }; - - __cuda_callable__ - RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity; - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); - else - return 0.0; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) - - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) - - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) - + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) - ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-vl/UpwindEnergy.h b/src/Examples/inviscid-flow-vl/UpwindEnergy.h deleted file mode 100644 index e3857cbcd..000000000 --- a/src/Examples/inviscid-flow-vl/UpwindEnergy.h +++ /dev/null @@ -1,507 +0,0 @@ -/*************************************************************************** - UpwindEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - UpwindEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "UpwindEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; - - MeshFunctionPointer density; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - __cuda_callable__ - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) - * ( - 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - }; - - __cuda_callable__ - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) - * ( - 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) - ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + velocity_other2 * velocity_other2 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + velocity_other2 * velocity_other2 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-vl/UpwindMomentumBase.h b/src/Examples/inviscid-flow-vl/UpwindMomentumBase.h deleted file mode 100644 index 93b470a28..000000000 --- a/src/Examples/inviscid-flow-vl/UpwindMomentumBase.h +++ /dev/null @@ -1,130 +0,0 @@ -/*************************************************************************** - UpwindMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - __cuda_callable__ - RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) - * ( ( 2.0 * speedOfSound ) / this->gamma ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); - else - return density * velocity * velocity + pressure; - }; - - __cuda_callable__ - RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity * velocity + pressure; - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) - * ( ( 2.0 * speedOfSound ) / this->gamma ) - * ( - 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); - else - return 0; - }; - - __cuda_callable__ - RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * velocity_other; - else - return density * velocity_main * velocity_other; - }; - - __cuda_callable__ - RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity_main * velocity_other; - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * velocity_other; - else - return 0.0; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - MeshFunctionPointer density; - -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-vl/UpwindMomentumX.h b/src/Examples/inviscid-flow-vl/UpwindMomentumX.h deleted file mode 100644 index ed49dda94..000000000 --- a/src/Examples/inviscid-flow-vl/UpwindMomentumX.h +++ /dev/null @@ -1,342 +0,0 @@ -/*************************************************************************** - UpwindMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ); - - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-vl/UpwindMomentumY.h b/src/Examples/inviscid-flow-vl/UpwindMomentumY.h deleted file mode 100644 index c2126d43a..000000000 --- a/src/Examples/inviscid-flow-vl/UpwindMomentumY.h +++ /dev/null @@ -1,318 +0,0 @@ -/*************************************************************************** - UpwindMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-vl/UpwindMomentumZ.h b/src/Examples/inviscid-flow-vl/UpwindMomentumZ.h deleted file mode 100644 index 97339e804..000000000 --- a/src/Examples/inviscid-flow-vl/UpwindMomentumZ.h +++ /dev/null @@ -1,276 +0,0 @@ -/*************************************************************************** - UpwindMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) - - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) - ); - } - - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-vl/euler.cpp b/src/Examples/inviscid-flow-vl/euler.cpp deleted file mode 100644 index 4d76005cb..000000000 --- a/src/Examples/inviscid-flow-vl/euler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "euler.h" diff --git a/src/Examples/inviscid-flow-vl/euler.cu b/src/Examples/inviscid-flow-vl/euler.cu deleted file mode 100644 index 4d76005cb..000000000 --- a/src/Examples/inviscid-flow-vl/euler.cu +++ /dev/null @@ -1 +0,0 @@ -#include "euler.h" diff --git a/src/Examples/inviscid-flow-vl/euler.h b/src/Examples/inviscid-flow-vl/euler.h deleted file mode 100644 index 75279e605..000000000 --- a/src/Examples/inviscid-flow-vl/euler.h +++ /dev/null @@ -1,116 +0,0 @@ -#include -#include -#include -#include -#include -#include "eulerProblem.h" -#include "Upwind.h" -#include "eulerRhs.h" -#include "eulerBuildConfigTag.h" - -#include "RiemannProblemInitialCondition.h" - -using namespace TNL; - -typedef eulerBuildConfigTag BuildConfig; - -/**** - * Uncomment the following (and comment the previous line) for the complete build. - * This will include support for all floating point precisions, all indexing types - * and more solvers. You may then choose between them from the command line. - * The compile time may, however, take tens of minutes or even several hours, - * especially if CUDA is enabled. Use this, if you want, only for the final build, - * not in the development phase. - */ -//typedef tnlDefaultConfigTag BuildConfig; - -template< typename ConfigTag >class eulerConfig -{ - public: - static void configSetup( Config::ConfigDescription & config ) - { - config.addDelimiter( "Inviscid flow settings:" ); - config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "dirichlet"); - config.addEntryEnum< String >( "dirichlet" ); - config.addEntryEnum< String >( "neumann" ); - config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); - typedef Meshes::Grid< 3 > Mesh; - RiemannProblemInitialCondition< Mesh >::configSetup( config ); - - /**** - * Add definition of your solver command line arguments. - */ - - } -}; - -template< typename Real, - typename Device, - typename Index, - typename MeshType, - typename ConfigTag, - typename SolverStarter, - typename Communicator > -class eulerSetter -{ - public: - - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - static bool run( const Config::ParameterContainer & parameters ) - { - enum { Dimension = MeshType::getMeshDimension() }; - typedef Upwind< MeshType, Real, Index > ApproximateOperator; - typedef eulerRhs< MeshType, Real > RightHandSide; - typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; - - /**** - * Resolve the template arguments of your solver here. - * The following code is for the Dirichlet and the Neumann boundary conditions. - * Both can be constant or defined as descrete values of Vector. - */ - String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); - if( parameters.checkParameter( "boundary-conditions-constant" ) ) - { - typedef Functions::Analytic::Constant< Dimension, Real > Constant; - if( boundaryConditionsType == "dirichlet" ) - { - typedef Operators::DirichletBoundaryConditions< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - typedef Operators::NeumannBoundaryConditions< MeshType, Constant, Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - typedef Functions::MeshFunction< MeshType > MeshFunction; - if( boundaryConditionsType == "dirichlet" ) - { - typedef Operators::DirichletBoundaryConditions< MeshType, MeshFunction, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "neumann" ) - { - typedef Operators::NeumannBoundaryConditions< MeshType, MeshFunction, Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - - return true;} - -}; - -int main( int argc, char* argv[] ) -{ - Solvers::Solver< eulerSetter, eulerConfig, BuildConfig > solver; - if( ! solver. run( argc, argv ) ) - return EXIT_FAILURE; - return EXIT_SUCCESS; -} diff --git a/src/Examples/inviscid-flow-vl/eulerBuildConfigTag.h b/src/Examples/inviscid-flow-vl/eulerBuildConfigTag.h deleted file mode 100644 index 073b6fb53..000000000 --- a/src/Examples/inviscid-flow-vl/eulerBuildConfigTag.h +++ /dev/null @@ -1,70 +0,0 @@ -#pragma once - -#include - -namespace TNL { - -class eulerBuildConfigTag{}; - -namespace Solvers { - -/**** - * Turn off support for float and long double. - */ -template<> struct ConfigTagReal< eulerBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct ConfigTagReal< eulerBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct ConfigTagIndex< eulerBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct ConfigTagIndex< eulerBuildConfigTag, long int >{ enum { enabled = false }; }; - -//template< int Dimension > struct ConfigTagDimension< eulerBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; - -/**** - * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. - */ -/* -template< int Dimension, typename Real, typename Device, typename Index > - struct ConfigTagMesh< eulerBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > - { enum { enabled = ConfigTagDimension< eulerBuildConfigTag, Dimension >::enabled && - ConfigTagReal< eulerBuildConfigTag, Real >::enabled && - ConfigTagDevice< eulerBuildConfigTag, Device >::enabled && - ConfigTagIndex< eulerBuildConfigTag, Index >::enabled }; }; -*/ - -/**** - * Please, chose your preferred time discretisation here. - */ -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; - -/**** - * Only the Runge-Kutta-Merson solver is enabled by default. - */ -template<> struct ConfigTagExplicitSolver< eulerBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; - -} // namespace Solvers - -namespace Meshes { -namespace BuildConfigTags { - -template< int Dimensions > struct GridDimensionTag< eulerBuildConfigTag, Dimensions >{ enum { enabled = ( Dimensions == 1 ) }; }; - -/**** - * Turn off support for float and long double. - */ -template<> struct GridRealTag< eulerBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct GridRealTag< eulerBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct GridIndexTag< eulerBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct GridIndexTag< eulerBuildConfigTag, long int >{ enum { enabled = false }; }; - -} // namespace BuildConfigTags -} // namespace Meshes -} // namespace TNL diff --git a/src/Examples/inviscid-flow-vl/eulerProblem.h b/src/Examples/inviscid-flow-vl/eulerProblem.h deleted file mode 100644 index a91e56176..000000000 --- a/src/Examples/inviscid-flow-vl/eulerProblem.h +++ /dev/null @@ -1,125 +0,0 @@ -/*************************************************************************** - eulerProblem.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include "CompressibleConservativeVariables.h" - - -using namespace TNL::Problems; - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -class eulerProblem: - public PDEProblem< Mesh, - Communicator, - typename InviscidOperators::RealType, - typename Mesh::DeviceType, - typename InviscidOperators::IndexType > -{ - public: - - typedef typename InviscidOperators::RealType RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef typename InviscidOperators::IndexType IndexType; - typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; - - using typename BaseType::MeshType; - using typename BaseType::MeshPointer; - using typename BaseType::DofVectorType; - using typename BaseType::DofVectorPointer; - - static const int Dimensions = Mesh::getMeshDimension(); - - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; - typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; - typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; - using CommunicatorType = Communicator; - - static String getTypeStatic(); - - String getPrologHeader() const; - - void writeProlog( Logger& logger, - const Config::ParameterContainer& parameters ) const; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ); - - bool setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ); - - template< typename Matrix > - bool setupLinearSystem( Matrix& matrix ); - - bool makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ); - - IndexType getDofs() const; - - void bindDofs( DofVectorPointer& dofs ); - - void getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ); - - void applyBoundaryConditions( const RealType& time, - DofVectorPointer& dofs ) - { - throw Exceptions::NotImplementedError( "TODO: implement BC ... see HeatEquationProblem" ); - } - - template< typename Matrix > - void assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs, - Matrix& matrix, - DofVectorPointer& rightHandSide ); - - bool postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ); - - protected: - - InviscidOperatorsPointer inviscidOperatorsPointer; - - BoundaryConditionPointer boundaryConditionPointer; - RightHandSidePointer rightHandSidePointer; - - ConservativeVariablesPointer conservativeVariables, - conservativeVariablesRHS; - - VelocityFieldPointer velocity; - MeshFunctionPointer pressure; - - RealType gamma; -}; - -} // namespace TNL - -#include "eulerProblem_impl.h" - diff --git a/src/Examples/inviscid-flow-vl/eulerProblem_impl.h b/src/Examples/inviscid-flow-vl/eulerProblem_impl.h deleted file mode 100644 index e0382e9c2..000000000 --- a/src/Examples/inviscid-flow-vl/eulerProblem_impl.h +++ /dev/null @@ -1,428 +0,0 @@ -/*************************************************************************** - eulerProblem_impl.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -#include "RiemannProblemInitialCondition.h" -#include "CompressibleConservativeVariables.h" -#include "PhysicalVariablesGetter.h" -#include "eulerProblem.h" - -#include "UpwindContinuity.h" -#include "UpwindEnergy.h" -#include "UpwindMomentumX.h" -#include "UpwindMomentumY.h" -#include "UpwindMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getTypeStatic() -{ - return String( "eulerProblem< " ) + Mesh :: getTypeStatic() + " >"; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getPrologHeader() const -{ - return String( "Inviscid flow solver" ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const -{ - /**** - * Add data you want to have in the computation report (log) as follows: - * logger.writeParameter< double >( "Parameter description", parameter ); - */ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setup( const Config::ParameterContainer& parameters, - const String& prefix ) -{ - if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || - ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || - ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) - return false; - this->gamma = parameters.getParameter< double >( "gamma" ); - velocity->setMesh( this->getMesh() ); - pressure->setMesh( this->getMesh() ); - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -typename eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >::IndexType -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getDofs() const -{ - /**** - * Return number of DOFs (degrees of freedom) i.e. number - * of unknowns to be resolved by the main solver. - */ - return this->conservativeVariables->getDofs( this->getMesh() ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -bindDofs( DofVectorPointer& dofVector ) -{ - this->conservativeVariables->bind( this->getMesh(), dofVector ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ) -{ - CompressibleConservativeVariables< MeshType > conservativeVariables; - conservativeVariables.bind( this->getMesh(), dofs ); - const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); - if( initialConditionType == "riemann-problem" ) - { - RiemannProblemInitialCondition< MeshType > initialCondition; - if( ! initialCondition.setup( parameters ) ) - return false; - initialCondition.setInitialCondition( conservativeVariables ); - return true; - } - std::cerr << "Unknown initial condition " << initialConditionType << std::endl; - return false; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > - template< typename Matrix > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setupLinearSystem( Matrix& matrix ) -{ -/* const IndexType dofs = this->getDofs( mesh ); - typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; - CompressedRowLengthsVectorType rowLengths; - if( ! rowLengths.setSize( dofs ) ) - return false; - MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; - matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, - differentialOperator, - boundaryCondition, - rowLengths ); - matrix.setDimensions( dofs, dofs ); - if( ! matrix.setCompressedRowLengths( rowLengths ) ) - return false;*/ - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ) -{ - std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; - - this->bindDofs( dofs ); - PhysicalVariablesGetter< MeshType > physicalVariablesGetter; - physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - FileName fileName; - fileName.setExtension( "tnl" ); - fileName.setIndex( step ); - fileName.setFileNameBase( "density-" ); - this->conservativeVariables->getDensity()->save( fileName.getFileName() ); - - fileName.setFileNameBase( "velocity-" ); - this->velocity->save( fileName.getFileName() ); - - fileName.setFileNameBase( "pressure-" ); - this->pressure->save( fileName.getFileName() ); - - fileName.setFileNameBase( "energy-" ); - this->conservativeVariables->getEnergy()->save( fileName.getFileName() ); - - fileName.setFileNameBase( "momentum-" ); - this->conservativeVariables->getMomentum()->save( fileName.getFileName() ); - - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ) -{ - typedef typename MeshType::Cell Cell; - const MeshPointer& mesh = this->getMesh(); - - /**** - * Bind DOFs - */ - this->conservativeVariables->bind( mesh, _u ); - this->conservativeVariablesRHS->bind( mesh, _fu ); - this->velocity->setMesh( mesh ); - this->pressure->setMesh( mesh ); - -// this->pressure->write( "pressure1", "gnuplot" ); -// getchar(); - /**** - * Resolve the physical variables - */ - PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; - physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - /**** - * Set-up operators - */ - typedef typename InviscidOperators::ContinuityOperatorType ContinuityOperatorType; - typedef typename InviscidOperators::MomentumXOperatorType MomentumXOperatorType; - typedef typename InviscidOperators::MomentumYOperatorType MomentumYOperatorType; - typedef typename InviscidOperators::MomentumZOperatorType MomentumZOperatorType; - typedef typename InviscidOperators::EnergyOperatorType EnergyOperatorType; - - this->inviscidOperatorsPointer->setTau( tau ); - this->inviscidOperatorsPointer->setVelocity( this->velocity ); - this->inviscidOperatorsPointer->setPressure( this->pressure ); - this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); - this->inviscidOperatorsPointer->setGamma( this->gamma ); - -// this->pressure->write( "pressure2", "gnuplot" ); -// getchar(); - /**** - * Continuity equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, ContinuityOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterContinuity; - explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); - explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterContinuity.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - this->conservativeVariables->getDensity(), - this->conservativeVariablesRHS->getDensity() ); - - /**** - * Momentum equations - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumXOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumX; - explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); - explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumX.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); - - if( Dimensions > 1 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumYOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumY; - explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); - explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumY.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); - } - - if( Dimensions > 2 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumZ; - explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); - explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumZ.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); - } - - - /**** - * Energy equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, EnergyOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterEnergy; - explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); - explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterEnergy.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - this->conservativeVariablesRHS->getEnergy(), // uRhoVelocityX, - this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); - -/* this->pressure->write( "pressure3", "gnuplot" ); - getchar(); - this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); - this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); - this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); - getchar();*/ - -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > - template< typename Matrix > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - Matrix& matrix, - DofVectorPointer& b ) -{ -/* LinearSystemAssembler< Mesh, - MeshFunctionType, - InviscidOperators, - BoundaryCondition, - RightHandSide, - BackwardTimeDiscretisation, - Matrix, - DofVectorType > systemAssembler; - - MeshFunction< Mesh > u( mesh, _u ); - systemAssembler.template assembly< typename Mesh::Cell >( time, - tau, - mesh, - this->differentialOperator, - this->boundaryCondition, - this->rightHandSide, - u, - matrix, - b );*/ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ) -{ - /* - typedef typename MeshType::Cell Cell; - int count = mesh->template getEntitiesCount< Cell >()/4; - //bind _u - this->_uRho.bind( *dofs, 0, count); - this->_uRhoVelocityX.bind( *dofs, count, count); - this->_uRhoVelocityY.bind( *dofs, 2 * count, count); - this->_uEnergy.bind( *dofs, 3 * count, count); - - MeshFunctionType velocity( mesh, this->velocity ); - MeshFunctionType velocityX( mesh, this->velocityX ); - MeshFunctionType velocityY( mesh, this->velocityY ); - MeshFunctionType pressure( mesh, this->pressure ); - MeshFunctionType uRho( mesh, _uRho ); - MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); - MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); - MeshFunctionType uEnergy( mesh, _uEnergy ); - //Generating differential operators - Velocity euler2DVelocity; - VelocityX euler2DVelocityX; - VelocityY euler2DVelocityY; - Pressure euler2DPressure; - - //velocityX - euler2DVelocityX.setRhoVelX(uRhoVelocityX); - euler2DVelocityX.setRho(uRho); -// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; -// velocityX = OFVelocityX; - - //velocityY - euler2DVelocityY.setRhoVelY(uRhoVelocityY); - euler2DVelocityY.setRho(uRho); -// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; -// velocityY = OFVelocityY; - - //velocity - euler2DVelocity.setVelX(velocityX); - euler2DVelocity.setVelY(velocityY); -// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; -// velocity = OFVelocity; - - //pressure - euler2DPressure.setGamma(gamma); - euler2DPressure.setVelocity(velocity); - euler2DPressure.setEnergy(uEnergy); - euler2DPressure.setRho(uRho); -// OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure; -// pressure = OFPressure; - */ - return true; -} - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow-vl/eulerRhs.h b/src/Examples/inviscid-flow-vl/eulerRhs.h deleted file mode 100644 index 51d4e0243..000000000 --- a/src/Examples/inviscid-flow-vl/eulerRhs.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef eulerRHS_H_ -#define eulerRHS_H_ - -#include - -namespace TNL { - -template< typename Mesh, typename Real >class eulerRhs - : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > - { - public: - - typedef Mesh MeshType; - typedef Real RealType; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; - } - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const Real& time = 0.0 ) const - { - typedef typename MeshEntity::MeshType::PointType PointType; - PointType v = entity.getCenter(); - return 0.0; - } -}; - -} //namespace TNL - -#endif /* eulerRHS_H_ */ diff --git a/src/Examples/inviscid-flow-vl/run-euler-vl b/src/Examples/inviscid-flow-vl/run-euler-vl deleted file mode 100644 index 9ebf9cbb5..000000000 --- a/src/Examples/inviscid-flow-vl/run-euler-vl +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 2 \ - --origin-x 0.0 \ - --origin-y 0.0 \ - --proportions-x 1.0 \ - --proportions-y 1.0 \ - --size-x 100 \ - --size-y 100 - -tnl-init --test-function sin-wave \ - --output-file init.tnl -tnl-euler-2d --initial-condition riemann-problem \ - --discontinuity-placement-0 0.3 \ - --discontinuity-placement-1 0.3 \ - --discontinuity-placement-2 0.3 \ - --time-discretisation explicit \ - --boundary-conditions-type neumann \ - --boundary-conditions-constant 0 \ - --discrete-solver euler \ - --time-step 0.0001 \ - --snapshot-period 0.01 \ - --final-time 1.0 - -tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/inviscid-flow/1d/MyMixedBoundaryConditions.h b/src/Examples/inviscid-flow/1d/MyMixedBoundaryConditions.h deleted file mode 100644 index 218805fa1..000000000 --- a/src/Examples/inviscid-flow/1d/MyMixedBoundaryConditions.h +++ /dev/null @@ -1,152 +0,0 @@ -// coppied and changed -/*************************************************************************** - tnlMyMixedBoundaryConditions.h - description - ------------------- - begin : Nov 17, 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 MYMIXEDBOUNDARYCONDITIONS_H_ -#define MYMIXEDBOUNDARYCONDITIONS_H_ - -#pragma once - -#include -#include -#include -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function = Functions::Analytic::Constant< Mesh::getMeshDimensions(), typename Mesh::RealType >, - int MeshEntitiesDimensions = Mesh::getMeshDimensions(), - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class MyMixedBoundaryConditions -: public Operator< Mesh, - Functions::MeshBoundaryDomain, - MeshEntitiesDimensions, - MeshEntitiesDimensions, - Real, - Index > -{ - public: - - typedef Mesh MeshType; - typedef Function FunctionType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - - typedef Pointers::SharedPointer< Mesh > MeshPointer; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef typename MeshType::VertexType VertexType; - - static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< MeshType, FunctionType >::template setup< MeshPointer >( this->function, meshPointer, parameters, prefix ); - } - - void setFunction( const Function& function ) - { - this->function = function; - } - - Function& getFunction() - { - return this->function; - } - - const Function& getFunction() const - { - return this->function; - } - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighbourEntities = entity.getNeighbourEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return u[ neighbourEntities.template getEntityIndex< 0 >() ]; - else - return u[ neighbourEntities.template getEntityIndex< -1 >() ]; - //tady se asi delaji okrajove podminky - //static_assert( EntityType::getDimensions() == MeshEntitiesDimensions, "Wrong mesh entity dimensions." ); - } - - template< typename EntityType > - __cuda_callable__ - IndexType getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 1; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - typename Matrix::MatrixRow matrixRow = matrix.getRow( entity.getIndex() ); - const IndexType& index = entity.getIndex(); - matrixRow.setElement( 0, index, 1.0 ); - b[ index ] = Functions::FunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); - } - - - protected: - - Function function; - - //static_assert( Device::DeviceType == Function::Device::DeviceType ); -}; - - -template< typename Mesh, - typename Function > -std::ostream& operator << ( std::ostream& str, const MyMixedBoundaryConditions< Mesh, Function >& bc ) -{ - str << "MyMixed boundary conditions: vector = " << bc.getVector(); - return str; -} - -} // namespace Operators -} // namespace TNL - -#endif /* MYMIXEDBOUNDARYCONDITIONS_H_ */ diff --git a/src/Examples/inviscid-flow/1d/MyNeumannBoundaryConditions.h b/src/Examples/inviscid-flow/1d/MyNeumannBoundaryConditions.h deleted file mode 100644 index 204be5a3f..000000000 --- a/src/Examples/inviscid-flow/1d/MyNeumannBoundaryConditions.h +++ /dev/null @@ -1,152 +0,0 @@ -//** coppied and changed -/*************************************************************************** - tnlMyNeumannBoundaryConditions.h - description - ------------------- - begin : Nov 17, 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 MYNEUMANNBOUNDARYCONDITIONS_H_ -#define MYNEUMANNBOUNDARYCONDITIONS_H_ - -#pragma once - -#include -#include -#include -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function = Functions::Analytic::Constant< Mesh::getMeshDimensions(), typename Mesh::RealType >, - int MeshEntitiesDimensions = Mesh::getMeshDimensions(), - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class MyNeumannBoundaryConditions -: public Operator< Mesh, - Functions::MeshBoundaryDomain, - MeshEntitiesDimensions, - MeshEntitiesDimensions, - Real, - Index > -{ - public: - - typedef Mesh MeshType; - typedef Function FunctionType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - - typedef Pointers::SharedPointer< Mesh > MeshPointer; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef typename MeshType::VertexType VertexType; - - static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< MeshType, FunctionType >::template setup< MeshPointer >( this->function, meshPointer, parameters, prefix ); - } - - void setFunction( const Function& function ) - { - this->function = function; - } - - Function& getFunction() - { - return this->function; - } - - const Function& getFunction() const - { - return this->function; - } - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighbourEntities = entity.getNeighbourEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return u[ neighbourEntities.template getEntityIndex< 1 >() ]; - else - return u[ neighbourEntities.template getEntityIndex< -1 >() ]; - //tady se asi delaji okrajove podminky - //static_assert( EntityType::getDimensions() == MeshEntitiesDimensions, "Wrong mesh entity dimensions." ); - } - - template< typename EntityType > - __cuda_callable__ - IndexType getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 1; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - typename Matrix::MatrixRow matrixRow = matrix.getRow( entity.getIndex() ); - const IndexType& index = entity.getIndex(); - matrixRow.setElement( 0, index, 1.0 ); - b[ index ] = Functions::FunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); - } - - - protected: - - Function function; - - //static_assert( Device::DeviceType == Function::Device::DeviceType ); -}; - - -template< typename Mesh, - typename Function > -std::ostream& operator << ( std::ostream& str, const MyNeumannBoundaryConditions< Mesh, Function >& bc ) -{ - str << "MyNeumann boundary conditions: vector = " << bc.getVector(); - return str; -} - -} // namespace Operators -} // namespace TNL - -#endif /* MYNEUMANNBOUNDARYCONDITIONS_H_ */ diff --git a/src/Examples/inviscid-flow/1d/tnl-run-euler-1d b/src/Examples/inviscid-flow/1d/tnl-run-euler-1d deleted file mode 100644 index 4829c27d0..000000000 --- a/src/Examples/inviscid-flow/1d/tnl-run-euler-1d +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 1 \ - --origin-x 0.0 \ - --proportions-x 1.0 \ - --size-x 100 - -#tnl-init --test-function sin-wave \ -# --output-file init.tnl -tnl-euler-1d-dbg --time-discretisation explicit \ - --time-step 2.5e-3 \ - --boundary-conditions-type myneumann \ - --discrete-solver euler \ - --snapshot-period 0.015 \ - --final-time 0.15 \ - --left-density 1.0 \ - --left-velocity -2.0 \ - --left-pressure 0.4 \ - --right-density 1.0 \ - --right-velocity 2.0 \ - --right-pressure 0.4 \ - --gamma 1.4 \ - --riemann-border 0.5 \ - -tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/inviscid-flow/2d/Euler2DVelXGetter.h b/src/Examples/inviscid-flow/2d/Euler2DVelXGetter.h deleted file mode 100644 index 2e79798a3..000000000 --- a/src/Examples/inviscid-flow/2d/Euler2DVelXGetter.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef EulerVelXGetter_H -#define EulerVelXGetter_H - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class EulerVelXGetter -: public Functions::Domain< Mesh::getMeshDimensions(), Functions::MeshDomain > -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef Real RealType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - - EulerVelXGetter( const MeshFunctionType& rho, - const MeshFunctionType& rhoVel) - : rho( rho ), rhoVel( rhoVel ) - {} - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - return this->operator[]( entity.getIndex() ); - } - - __cuda_callable__ - Real operator[]( const IndexType& idx ) const - { - if (this->rho[ idx ]==0) return 0; else return this->rhoVel[ idx ] / this->rho[ idx ]; - } - - - protected: - - const MeshFunctionType& rho; - - const MeshFunctionType& rhoVel; - -}; - -} // namespace TNL - -#endif /* EulerVelXGetter_H */ diff --git a/src/Examples/inviscid-flow/2d/MyMixedBoundaryConditions.h b/src/Examples/inviscid-flow/2d/MyMixedBoundaryConditions.h deleted file mode 100644 index dbcd6b5d2..000000000 --- a/src/Examples/inviscid-flow/2d/MyMixedBoundaryConditions.h +++ /dev/null @@ -1,175 +0,0 @@ -// coppied and changed -/*************************************************************************** - tnlMyMixedBoundaryConditions.h - description - ------------------- - begin : Nov 17, 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 MYMIXEDBOUNDARYCONDITIONS_H_ -#define MYMIXEDBOUNDARYCONDITIONS_H_ - -#pragma once - -#include -#include -#include -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function = Functions::Analytic::Constant< Mesh::getMeshDimensions(), typename Mesh::RealType >, - int MeshEntitiesDimensions = Mesh::getMeshDimensions(), - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class MyMixedBoundaryConditions -: public Operator< Mesh, - Functions::MeshBoundaryDomain, - MeshEntitiesDimensions, - MeshEntitiesDimensions, - Real, - Index > -{ - public: - - typedef Mesh MeshType; - typedef Function FunctionType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - - typedef Pointers::SharedPointer< Mesh > MeshPointer; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef typename MeshType::VertexType VertexType; - - static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< MeshType, FunctionType >::template setup< MeshPointer >( this->function, meshPointer, parameters, prefix ); - } - - void setFunction( const Function& function ) - { - this->function = function; - } - - Function& getFunction() - { - return this->function; - } - - const Function& getFunction() const - { - return this->function; - } - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighbourEntities = entity.getNeighbourEntities(); - typedef typename MeshType::Cell Cell; - int count = mesh.template getEntitiesCount< Cell >(); - count = std::sqrt(count); - float x0 = 0.5; - if( entity.getCoordinates().x() == 0 ) - { - if ( entity.getCoordinates().y() < count * x0 ) - return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - else if( entity.getCoordinates().y() < count -1 ) - return u[ neighbourEntities.template getEntityIndex< 1, 0 >() ]; - else if( entity.getCoordinates().y() == count ) - return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - } - else if( entity.getCoordinates().y() == 0 ) - { - if ( entity.getCoordinates().x() < count * x0 ) - return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - else if( entity.getCoordinates().x() < count -1 ) - return u[ neighbourEntities.template getEntityIndex< 0, 1 >() ]; - else if( entity.getCoordinates().y() == count ) - return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - } - else if( entity.getCoordinates().x() == count ) - return u[ neighbourEntities.template getEntityIndex< -1, 0 >() ]; - else if( entity.getCoordinates().y() == count ) - return u[ neighbourEntities.template getEntityIndex< 0, -1 >() ]; - else return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - //tady se asi delaji okrajove podminky - //static_assert( EntityType::getDimensions() == MeshEntitiesDimensions, "Wrong mesh entity dimensions." ); - return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - } - - template< typename EntityType > - __cuda_callable__ - IndexType getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 1; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - typename Matrix::MatrixRow matrixRow = matrix.getRow( entity.getIndex() ); - const IndexType& index = entity.getIndex(); - matrixRow.setElement( 0, index, 1.0 ); - b[ index ] = Functions::FunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); - } - - - protected: - - Function function; - - //static_assert( Device::DeviceType == Function::Device::DeviceType ); -}; - - -template< typename Mesh, - typename Function > -std::ostream& operator << ( std::ostream& str, const MyMixedBoundaryConditions< Mesh, Function >& bc ) -{ - str << "MyMixed boundary conditions: vector = " << bc.getVector(); - return str; -} - -} // namespace Operators -} // namespace TNL - -#endif /* MYMIXEDBOUNDARYCONDITIONS_H_ */ diff --git a/src/Examples/inviscid-flow/2d/MyNeumannBoundaryConditions.h b/src/Examples/inviscid-flow/2d/MyNeumannBoundaryConditions.h deleted file mode 100644 index 1db632bf5..000000000 --- a/src/Examples/inviscid-flow/2d/MyNeumannBoundaryConditions.h +++ /dev/null @@ -1,157 +0,0 @@ -//** coppied and changed -/*************************************************************************** - tnlMyNeumannBoundaryConditions.h - description - ------------------- - begin : Nov 17, 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 MYNEUMANNBOUNDARYCONDITIONS_H_ -#define MYNEUMANNBOUNDARYCONDITIONS_H_ - -#pragma once - -#include -#include -#include -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function = Functions::Analytic::Constant< Mesh::getMeshDimensions(), typename Mesh::RealType >, - int MeshEntitiesDimensions = Mesh::getMeshDimensions(), - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class MyNeumannBoundaryConditions -: public Operator< Mesh, - Functions::MeshBoundaryDomain, - MeshEntitiesDimensions, - MeshEntitiesDimensions, - Real, - Index > -{ - public: - - typedef Mesh MeshType; - typedef Function FunctionType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - - typedef Pointers::SharedPointer< Mesh > MeshPointer; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef typename MeshType::VertexType VertexType; - - static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; //Functions::FunctionAdapter< MeshType, FunctionType >::template setup< MeshPointer >( this->function, meshPointer, parameters, prefix ); - } - - void setFunction( const Function& function ) - { - this->function = function; - } - - Function& getFunction() - { - return this->function; - } - - const Function& getFunction() const - { - return this->function; - } - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighbourEntities = entity.getNeighbourEntities(); - typedef typename MeshType::Cell Cell; - int count = mesh.template getEntitiesCount< Cell >(); - count = std::sqrt(count); - if( entity.getCoordinates().x() == 0 ) - return u[ neighbourEntities.template getEntityIndex< 1, 0 >() ]; - else if( entity.getCoordinates().x() == count-1 ) - return u[ neighbourEntities.template getEntityIndex< -1, 0 >() ]; - else if( entity.getCoordinates().y() == 0 ) - return u[ neighbourEntities.template getEntityIndex< 0, 1 >() ]; - else return u[ neighbourEntities.template getEntityIndex< 0, -1 >() ]; - //tady se asi delaji okrajove podminky - //static_assert( EntityType::getDimensions() == MeshEntitiesDimensions, "Wrong mesh entity dimensions." ); - } - - template< typename EntityType > - __cuda_callable__ - IndexType getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 1; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - typename Matrix::MatrixRow matrixRow = matrix.getRow( entity.getIndex() ); - const IndexType& index = entity.getIndex(); - matrixRow.setElement( 0, index, 1.0 ); - b[ index ] = Functions::FunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); - } - - - protected: - - Function function; - - //static_assert( Device::DeviceType == Function::Device::DeviceType ); -}; - - -template< typename Mesh, - typename Function > -std::ostream& operator << ( std::ostream& str, const MyNeumannBoundaryConditions< Mesh, Function >& bc ) -{ - str << "MyNeumann boundary conditions: vector = " << bc.getVector(); - return str; -} - -} // namespace Operators -} // namespace TNL - -#endif /* MYNEUMANNBOUNDARYCONDITIONS_H_ */ diff --git a/src/Examples/inviscid-flow/2d/tnl-run-euler-2d b/src/Examples/inviscid-flow/2d/tnl-run-euler-2d deleted file mode 100644 index 463dd3506..000000000 --- a/src/Examples/inviscid-flow/2d/tnl-run-euler-2d +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 2 \ - --origin-x 0.0 \ - --origin-y 0.0 \ - --proportions-x 1.0 \ - --proportions-y 1.0 \ - --size-x 400 \ - --size-y 400 - -#tnl-init --test-function sin-wave \ -# --output-file init.tnl -# --boundary-conditions-type neumann \ -# --boundary-conditions-constant 0 \ - -tnl-euler-2d-dbg --time-discretisation explicit \ - --time-step 5.0e-4 \ - --boundary-conditions-type myneumann \ - --discrete-solver euler \ - --snapshot-period 0.03 \ - --final-time 0.3 \ - --NW-density 0.5323 \ - --NW-velocityX 1.206 \ - --NW-velocityY 0.0 \ - --NW-pressure 0.3 \ - --NE-density 1.5 \ - --NE-velocityX 0.0 \ - --NE-velocityY 0.0 \ - --NE-pressure 1.5 \ - --SW-density 0.138 \ - --SW-velocityX 1.206 \ - --SW-velocityY 1.206 \ - --SW-pressure 0.029 \ - --SE-density 0.5323 \ - --SE-velocityX 0 \ - --SE-velocityY 1.206 \ - --SE-pressure 0.3 \ - --gamma 1.4 \ - --riemann-border 0.5 \ - -tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/inviscid-flow/3d/CMakeLists.txt b/src/Examples/inviscid-flow/3d/CMakeLists.txt deleted file mode 100644 index 41096a73a..000000000 --- a/src/Examples/inviscid-flow/3d/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -set( tnl_heat_equation_SOURCES - euler.cpp - euler-cuda.cu ) - -IF( BUILD_CUDA ) - CUDA_ADD_EXECUTABLE(tnl-euler-3d${debugExt} euler-cuda.cu) - target_link_libraries (tnl-euler-3d${debugExt} tnl${debugExt}-${tnlVersion} ${CUSPARSE_LIBRARY} ) -ELSE( BUILD_CUDA ) - ADD_EXECUTABLE(tnl-euler-3d${debugExt} euler.cpp) - target_link_libraries (tnl-euler-3d${debugExt} tnl${debugExt}-${tnlVersion} ) -ENDIF( BUILD_CUDA ) - - -INSTALL( TARGETS tnl-euler-3d${debugExt} - RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) - -INSTALL( FILES run-euler - ${tnl_heat_equation_SOURCES} - DESTINATION share/tnl-${tnlVersion}/examples/inviscid-flow-3d ) - diff --git a/src/Examples/inviscid-flow/3d/Euler2DVelXGetter.h b/src/Examples/inviscid-flow/3d/Euler2DVelXGetter.h deleted file mode 100644 index 2e79798a3..000000000 --- a/src/Examples/inviscid-flow/3d/Euler2DVelXGetter.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef EulerVelXGetter_H -#define EulerVelXGetter_H - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class EulerVelXGetter -: public Functions::Domain< Mesh::getMeshDimensions(), Functions::MeshDomain > -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef Real RealType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - - EulerVelXGetter( const MeshFunctionType& rho, - const MeshFunctionType& rhoVel) - : rho( rho ), rhoVel( rhoVel ) - {} - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - return this->operator[]( entity.getIndex() ); - } - - __cuda_callable__ - Real operator[]( const IndexType& idx ) const - { - if (this->rho[ idx ]==0) return 0; else return this->rhoVel[ idx ] / this->rho[ idx ]; - } - - - protected: - - const MeshFunctionType& rho; - - const MeshFunctionType& rhoVel; - -}; - -} // namespace TNL - -#endif /* EulerVelXGetter_H */ diff --git a/src/Examples/inviscid-flow/3d/EulerPressureGetter.h b/src/Examples/inviscid-flow/3d/EulerPressureGetter.h deleted file mode 100644 index 45611c647..000000000 --- a/src/Examples/inviscid-flow/3d/EulerPressureGetter.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef EulerPressureGetter_H -#define EulerPressureGetter_H - -#include -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class EulerPressureGetter -: public Functions::Domain< Mesh::getMeshDimensions(), Functions::MeshDomain > -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef Real RealType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - - EulerPressureGetter( const MeshFunctionType& rho, - const MeshFunctionType& rhoVelX, - const MeshFunctionType& rhoVelY, - const MeshFunctionType& rhoVelZ, - const MeshFunctionType& energy, - const RealType& gamma ) - : rho( rho ), rhoVelX( rhoVelX ), rhoVelY( rhoVelY ), rhoVelZ( rhoVelZ ), energy( energy ), gamma( gamma ) - {} - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - return this->operator[]( entity.getIndex() ); - } - - __cuda_callable__ - Real operator[]( const IndexType& idx ) const - { -/* if (this->rho[ idx ]==0) return 0; - else return ( this->gamma - 1.0 ) * ( this->energy[ idx ] - 0.5 * this->rho[ idx ] * - ( std::pow(this->rhoVelX[ idx ] / this->rho[ idx ],2) + std::pow(this->rhoVelY[ idx ] / this->rho[ idx ],2) + std::pow(this->rhoVelZ[ idx ] / this->rho[ idx ],2) ); -*/ return ( this->gamma - 1.0 ) * ( this->energy[ idx ] * this->rho[ idx ] ); - } - - - protected: - - const MeshFunctionType& rho; - - const MeshFunctionType& rhoVelX; - - const MeshFunctionType& rhoVelY; - - const MeshFunctionType& rhoVelZ; - - const MeshFunctionType& energy; - - RealType gamma; - -}; - -} //namespace TNL - -#endif /* EulerPressureGetter_H */ diff --git a/src/Examples/inviscid-flow/3d/EulerVelGetter.h b/src/Examples/inviscid-flow/3d/EulerVelGetter.h deleted file mode 100644 index 24d06eaf5..000000000 --- a/src/Examples/inviscid-flow/3d/EulerVelGetter.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef EulerVelGetter_H -#define EulerVelGetter_H - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class EulerVelGetter -: public Functions::Domain< Mesh::getMeshDimensions(), Functions::MeshDomain > -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef Real RealType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - - EulerVelGetter( const MeshFunctionType& rho, - const MeshFunctionType& rhoVelX, - const MeshFunctionType& rhoVelY, - const MeshFunctionType& rhoVelZ) - : rho( rho ), rhoVelX( rhoVelX ), rhoVelY( rhoVelY ), rhoVelZ( rhoVelZ ) - {} - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - return this->operator[]( entity.getIndex() ); - } - - __cuda_callable__ - Real operator[]( const IndexType& idx ) const - { - if (this->rho[ idx ]==0) return 0; else return std::sqrt( std::pow( this->rhoVelX[ idx ] / this->rho[ idx ], 2) + std::pow( this->rhoVelY[ idx ] / this->rho[ idx ], 2) + std::pow( this->rhoVelZ[ idx ] / this->rho[ idx ], 2) ) ; - } - - - protected: - - const MeshFunctionType& rho; - - const MeshFunctionType& rhoVelX; - - const MeshFunctionType& rhoVelY; - - const MeshFunctionType& rhoVelZ; - -}; - -} // namespace TNL - -#endif /* EulerVelGetter_H */ diff --git a/src/Examples/inviscid-flow/3d/LaxFridrichs3D.h b/src/Examples/inviscid-flow/3d/LaxFridrichs3D.h deleted file mode 100644 index 57c9fe6b4..000000000 --- a/src/Examples/inviscid-flow/3d/LaxFridrichs3D.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef LaxFridrichs3D_H -#define LaxFridrichs3D_H - -#include -#include -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" -#include "EulerPressureGetter.h" -#include "Euler2DVelXGetter.h" -#include "EulerVelGetter.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichs3D -{ - public: - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - - typedef LaxFridrichsContinuity< Mesh, Real, Index > Continuity; - typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumX; - typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumY; - typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZ; - typedef LaxFridrichsEnergy< Mesh, Real, Index > Energy; - typedef EulerVelXGetter< Mesh, Real, Index > VelocityX; - typedef EulerVelGetter< Mesh, Real, Index > Velocity; - typedef EulerPressureGetter< Mesh, Real, Index > Pressure; - -}; - -} //namespace TNL - -#endif /* LaxFridrichs3D_H */ diff --git a/src/Examples/inviscid-flow/3d/LaxFridrichsContinuity_impl .h b/src/Examples/inviscid-flow/3d/LaxFridrichsContinuity_impl .h deleted file mode 100644 index ac469a524..000000000 --- a/src/Examples/inviscid-flow/3d/LaxFridrichsContinuity_impl .h +++ /dev/null @@ -1,350 +0,0 @@ -#ifndef LaxFridrichsContinuity_IMPL_H -#define LaxFridrichsContinuity_IMPL_H - -namespace TNL { - -/**** - * 1D problem - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -String -LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index >:: -getType() -{ - return String( "LaxFridrichsContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename MeshFunction, typename MeshEntity > -__cuda_callable__ -Real -LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index >:: -operator()( const MeshFunction& u, - const MeshEntity& entity, - const Real& time ) const -{ - /**** - * Implement your explicit form of the differential operator here. - * The following example is the Laplace operator approximated - * by the Finite difference method. - */ - static_assert( MeshEntity::entityDimensions == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimensions() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighbourEntities< 1 >& neighbourEntities = entity.getNeighbourEntities(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighbourEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighbourEntities.template getEntityIndex< -1 >(); - return ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) * hxSquareInverse; -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename MeshEntity > -__cuda_callable__ -Index -LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index >:: -getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const -{ - /**** - * Return a number of non-zero elements in a line (associated with given grid element) of - * the linear system. - * The following example is the Laplace operator approximated - * by the Finite difference method. - */ - - return 2*Dimensions + 1; -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > - template< typename MeshEntity, typename Vector, typename MatrixRow > -__cuda_callable__ -void -LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index >:: -updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const -{ - /**** - * Setup the non-zero elements of the linear system here. - * The following example is the Laplace operator appriximated - * by the Finite difference method. - */ - - const typename MeshEntity::template NeighbourEntities< 1 >& neighbourEntities = entity.getNeighbourEntities(); - const RealType& lambdaX = tau * entity.getMesh().template getSpaceStepsProducts< -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighbourEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighbourEntities.template getEntityIndex< -1 >(); - matrixRow.setElement( 0, west, - lambdaX ); - matrixRow.setElement( 1, center, 2.0 * lambdaX ); - matrixRow.setElement( 2, east, - lambdaX ); -} - -/**** - * 2D problem - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -String -LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: -getType() -{ - return String( "LaxFridrichsContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename MeshFunction, typename MeshEntity > -__cuda_callable__ -Real -LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: -operator()( const MeshFunction& u, - const MeshEntity& entity, - const Real& time ) const -{ - /**** - * Implement your explicit form of the differential operator here. - * The following example is the Laplace operator approximated - * by the Finite difference method. - */ - static_assert( MeshEntity::entityDimensions == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimensions() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighbourEntities< 2 >& neighbourEntities = entity.getNeighbourEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighbourEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighbourEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighbourEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighbourEntities.template getEntityIndex< 0, -1 >(); - return (0.25 / this->tau) * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - - 0.5 * hxInverse * ( u[ east ] * this->velocityX[ east ] - u[ west ] * this->velocityX[ west ] ) - - 0.5 * hyInverse * ( u[ north ] * this->velocityY[ north ] - u[ south ] * this->velocityY[ south ] ); -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename MeshEntity > -__cuda_callable__ -Index -LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: -getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const -{ - /**** - * Return a number of non-zero elements in a line (associated with given grid element) of - * the linear system. - * The following example is the Laplace operator approximated - * by the Finite difference method. - */ - - return 2*Dimensions + 1; -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > - template< typename MeshEntity, typename Vector, typename MatrixRow > -__cuda_callable__ -void -LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index >:: -updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const -{ - /**** - * Setup the non-zero elements of the linear system here. - * The following example is the Laplace operator appriximated - * by the Finite difference method. - */ - - const typename MeshEntity::template NeighbourEntities< 2 >& neighbourEntities = entity.getNeighbourEntities(); - const RealType& lambdaX = tau * entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& lambdaY = tau * entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighbourEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighbourEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighbourEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighbourEntities.template getEntityIndex< 0, -1 >(); - matrixRow.setElement( 0, south, -lambdaY ); - matrixRow.setElement( 1, west, -lambdaX ); - matrixRow.setElement( 2, center, 2.0 * ( lambdaX + lambdaY ) ); - matrixRow.setElement( 3, east, -lambdaX ); - matrixRow.setElement( 4, north, -lambdaY ); -} - -/**** - * 3D problem - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -String -LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index >:: -getType() -{ - return String( "LaxFridrichsContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename MeshFunction, typename MeshEntity > -__cuda_callable__ -Real -LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index >:: -operator()( const MeshFunction& u, - const MeshEntity& entity, - const Real& time ) const -{ - /**** - * Implement your explicit form of the differential operator here. - * The following example is the Laplace operator approximated - * by the Finite difference method. - */ - static_assert( MeshEntity::entityDimensions == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimensions() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighbourEntities< 3 >& neighbourEntities = entity.getNeighbourEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighbourEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighbourEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighbourEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighbourEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighbourEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighbourEntities.template getEntityIndex< 0, 0, -1 >(); - return ((1.0/6.0) / this->tau) * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ] - 6.0 * u[ center ] ) - - 0.5 * hxInverse * ( u[ east ] * this->velocityX[ east ] - u[ west ] * this->velocityX[ west ] ) - - 0.5 * hyInverse * ( u[ north ] * this->velocityY[ north ] - u[ south ] * this->velocityY[ south ] ) - - 0.5 * hzInverse * ( u[ up ] * this->velocityZ[ up ] - u[ down ] * this->velocityZ[ down ] ); -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -template< typename MeshEntity > -__cuda_callable__ -Index -LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index >:: -getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const -{ - /**** - * Return a number of non-zero elements in a line (associated with given grid element) of - * the linear system. - * The following example is the Laplace operator approximated - * by the Finite difference method. - */ - - return 2*Dimensions + 1; -} - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > - template< typename MeshEntity, typename Vector, typename MatrixRow > -__cuda_callable__ -void -LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index >:: -updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const -{ - /**** - * Setup the non-zero elements of the linear system here. - * The following example is the Laplace operator appriximated - * by the Finite difference method. - */ - - const typename MeshEntity::template NeighbourEntities< 3 >& neighbourEntities = entity.getNeighbourEntities(); - const RealType& lambdaX = tau * entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& lambdaY = tau * entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& lambdaZ = tau * entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighbourEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighbourEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighbourEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighbourEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighbourEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighbourEntities.template getEntityIndex< 0, 0, -1 >(); - matrixRow.setElement( 0, down, -lambdaZ ); - matrixRow.setElement( 1, south, -lambdaY ); - matrixRow.setElement( 2, west, -lambdaX ); - matrixRow.setElement( 3, center, 2.0 * ( lambdaX + lambdaY + lambdaZ ) ); - matrixRow.setElement( 4, east, -lambdaX ); - matrixRow.setElement( 5, north, -lambdaY ); - matrixRow.setElement( 6, up, -lambdaZ ); -} - -} //namespace TNL - -#endif /* LaxFridrichsContinuityIMPL_H */ - diff --git a/src/Examples/inviscid-flow/3d/LaxFridrichsEnergy.h b/src/Examples/inviscid-flow/3d/LaxFridrichsEnergy.h deleted file mode 100644 index 9083970ae..000000000 --- a/src/Examples/inviscid-flow/3d/LaxFridrichsEnergy.h +++ /dev/null @@ -1,237 +0,0 @@ -#ifndef LaxFridrichsEnergy_H -#define LaxFridrichsEnergy_H - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 1,MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - Real tau; - MeshFunctionType velocityX; - MeshFunctionType velocityY; - MeshFunctionType velocityZ; - MeshFunctionType pressure; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocityX(MeshFunctionType& velocityX) - { - this->velocityX.bind(velocityX); - }; - - void setVelocityY(MeshFunctionType& velocityY) - { - this->velocityY.bind(velocityY); - }; - - void setVelocityZ(MeshFunctionType& velocityZ) - { - this->velocityZ.bind(velocityZ); - }; - - void setPressure(MeshFunctionType& pressure) - { - this->pressure.bind(pressure); - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const; - - template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const; -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 2,MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - Real tau; - MeshFunctionType velocityX; - MeshFunctionType velocityY; - MeshFunctionType velocityZ; - MeshFunctionType pressure; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocityX(MeshFunctionType& velocityX) - { - this->velocityX.bind(velocityX); - }; - - void setVelocityY(MeshFunctionType& velocityY) - { - this->velocityY.bind(velocityY); - }; - - void setVelocityZ(MeshFunctionType& velocityZ) - { - this->velocityZ.bind(velocityZ); - }; - - void setPressure(MeshFunctionType& pressure) - { - this->pressure.bind(pressure); - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const; - - template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const; -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - Real tau; - MeshFunctionType velocityX; - MeshFunctionType velocityY; - MeshFunctionType velocityZ; - MeshFunctionType pressure; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocityX(MeshFunctionType& velocityX) - { - this->velocityX.bind(velocityX); - }; - - void setVelocityY(MeshFunctionType& velocityY) - { - this->velocityY.bind(velocityY); - }; - - void setVelocityZ(MeshFunctionType& velocityZ) - { - this->velocityZ.bind(velocityZ); - }; - - void setPressure(MeshFunctionType& pressure) - { - this->pressure.bind(pressure); - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const; - - template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const; -}; - -} //namespace TNL - - -#include "LaxFridrichsEnergy_impl.h" - -#endif /* LaxFridrichsEnergy_H */ diff --git a/src/Examples/inviscid-flow/3d/LaxFridrichsMomentumX.h b/src/Examples/inviscid-flow/3d/LaxFridrichsMomentumX.h deleted file mode 100644 index 5d1cf9192..000000000 --- a/src/Examples/inviscid-flow/3d/LaxFridrichsMomentumX.h +++ /dev/null @@ -1,237 +0,0 @@ -#ifndef LaxFridrichsMomentumX_H -#define LaxFridrichsMomentumX_H - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 1,MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - Real tau; - MeshFunctionType velocityX; - MeshFunctionType velocityY; - MeshFunctionType velocityZ; - MeshFunctionType pressure; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocityX(MeshFunctionType& velocityX) - { - this->velocityX.bind(velocityX); - }; - - void setVelocityY(MeshFunctionType& velocityY) - { - this->velocityY.bind(velocityY); - }; - - void setVelocityZ(MeshFunctionType& velocityZ) - { - this->velocityZ.bind(velocityZ); - }; - - void setPressure(MeshFunctionType& pressure) - { - this->pressure.bind(pressure); - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const; - - template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const; -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 2,MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - Real tau; - MeshFunctionType velocityX; - MeshFunctionType velocityY; - MeshFunctionType velocityZ; - MeshFunctionType pressure; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocityX(MeshFunctionType& velocityX) - { - this->velocityX.bind(velocityX); - }; - - void setVelocityY(MeshFunctionType& velocityY) - { - this->velocityY.bind(velocityY); - }; - - void setVelocityZ(MeshFunctionType& velocityZ) - { - this->velocityZ.bind(velocityZ); - }; - - void setPressure(MeshFunctionType& pressure) - { - this->pressure.bind(pressure); - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const; - - template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const; -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - Real tau; - MeshFunctionType velocityX; - MeshFunctionType velocityY; - MeshFunctionType velocityZ; - MeshFunctionType pressure; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocityX(MeshFunctionType& velocityX) - { - this->velocityX.bind(velocityX); - }; - - void setVelocityY(MeshFunctionType& velocityY) - { - this->velocityY.bind(velocityY); - }; - - void setVelocityZ(MeshFunctionType& velocityZ) - { - this->velocityZ.bind(velocityZ); - }; - - void setPressure(MeshFunctionType& pressure) - { - this->pressure.bind(pressure); - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const; - - template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const; -}; - - -} // namespace TNL - -#include "LaxFridrichsMomentumX_impl.h" - -#endif /* LaxFridrichsMomentumX_H */ diff --git a/src/Examples/inviscid-flow/3d/LaxFridrichsMomentumZ.h b/src/Examples/inviscid-flow/3d/LaxFridrichsMomentumZ.h deleted file mode 100644 index 0d7882f6d..000000000 --- a/src/Examples/inviscid-flow/3d/LaxFridrichsMomentumZ.h +++ /dev/null @@ -1,236 +0,0 @@ -#ifndef LaxFridrichsMomentumZ_H -#define LaxFridrichsMomentumZ_H - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 1,MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - Real tau; - MeshFunctionType velocityX; - MeshFunctionType velocityY; - MeshFunctionType velocityZ; - MeshFunctionType pressure; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocityX(MeshFunctionType& velocityX) - { - this->velocityX.bind(velocityX); - }; - - void setVelocityY(MeshFunctionType& velocityY) - { - this->velocityY.bind(velocityY); - }; - - void setVelocityZ(MeshFunctionType& velocityZ) - { - this->velocityZ.bind(velocityZ); - }; - - void setPressure(MeshFunctionType& pressure) - { - this->pressure.bind(pressure); - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const; - - template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const; -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 2,MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - Real tau; - MeshFunctionType velocityX; - MeshFunctionType velocityY; - MeshFunctionType velocityZ; - MeshFunctionType pressure; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocityX(MeshFunctionType& velocityX) - { - this->velocityX.bind(velocityX); - }; - - void setVelocityY(MeshFunctionType& velocityY) - { - this->velocityY.bind(velocityY); - }; - - void setVelocityZ(MeshFunctionType& velocityZ) - { - this->velocityZ.bind(velocityZ); - }; - - void setPressure(MeshFunctionType& pressure) - { - this->pressure.bind(pressure); - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const; - - template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const; -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - enum { Dimensions = MeshType::getMeshDimensions() }; - - static String getType(); - Real tau; - MeshFunctionType velocityX; - MeshFunctionType velocityY; - MeshFunctionType velocityZ; - MeshFunctionType pressure; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocityX(MeshFunctionType& velocityX) - { - this->velocityX.bind(velocityX); - }; - - void setVelocityY(MeshFunctionType& velocityY) - { - this->velocityY.bind(velocityY); - }; - - void setVelocityZ(MeshFunctionType& velocityZ) - { - this->velocityZ.bind(velocityZ); - }; - - void setPressure(MeshFunctionType& pressure) - { - this->pressure.bind(pressure); - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const; - - template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const; -}; - -} // namespace TNL - -#include "LaxFridrichsMomentumZ_impl.h" - -#endif /* LaxFridrichsMomentumZ_H */ diff --git a/src/Examples/inviscid-flow/3d/MyMixedBoundaryConditions.h b/src/Examples/inviscid-flow/3d/MyMixedBoundaryConditions.h deleted file mode 100644 index dbcd6b5d2..000000000 --- a/src/Examples/inviscid-flow/3d/MyMixedBoundaryConditions.h +++ /dev/null @@ -1,175 +0,0 @@ -// coppied and changed -/*************************************************************************** - tnlMyMixedBoundaryConditions.h - description - ------------------- - begin : Nov 17, 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 MYMIXEDBOUNDARYCONDITIONS_H_ -#define MYMIXEDBOUNDARYCONDITIONS_H_ - -#pragma once - -#include -#include -#include -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function = Functions::Analytic::Constant< Mesh::getMeshDimensions(), typename Mesh::RealType >, - int MeshEntitiesDimensions = Mesh::getMeshDimensions(), - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class MyMixedBoundaryConditions -: public Operator< Mesh, - Functions::MeshBoundaryDomain, - MeshEntitiesDimensions, - MeshEntitiesDimensions, - Real, - Index > -{ - public: - - typedef Mesh MeshType; - typedef Function FunctionType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - - typedef Pointers::SharedPointer< Mesh > MeshPointer; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef typename MeshType::VertexType VertexType; - - static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< MeshType, FunctionType >::template setup< MeshPointer >( this->function, meshPointer, parameters, prefix ); - } - - void setFunction( const Function& function ) - { - this->function = function; - } - - Function& getFunction() - { - return this->function; - } - - const Function& getFunction() const - { - return this->function; - } - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighbourEntities = entity.getNeighbourEntities(); - typedef typename MeshType::Cell Cell; - int count = mesh.template getEntitiesCount< Cell >(); - count = std::sqrt(count); - float x0 = 0.5; - if( entity.getCoordinates().x() == 0 ) - { - if ( entity.getCoordinates().y() < count * x0 ) - return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - else if( entity.getCoordinates().y() < count -1 ) - return u[ neighbourEntities.template getEntityIndex< 1, 0 >() ]; - else if( entity.getCoordinates().y() == count ) - return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - } - else if( entity.getCoordinates().y() == 0 ) - { - if ( entity.getCoordinates().x() < count * x0 ) - return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - else if( entity.getCoordinates().x() < count -1 ) - return u[ neighbourEntities.template getEntityIndex< 0, 1 >() ]; - else if( entity.getCoordinates().y() == count ) - return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - } - else if( entity.getCoordinates().x() == count ) - return u[ neighbourEntities.template getEntityIndex< -1, 0 >() ]; - else if( entity.getCoordinates().y() == count ) - return u[ neighbourEntities.template getEntityIndex< 0, -1 >() ]; - else return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - //tady se asi delaji okrajove podminky - //static_assert( EntityType::getDimensions() == MeshEntitiesDimensions, "Wrong mesh entity dimensions." ); - return u[ neighbourEntities.template getEntityIndex< 0, 0 >() ]; - } - - template< typename EntityType > - __cuda_callable__ - IndexType getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 1; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - typename Matrix::MatrixRow matrixRow = matrix.getRow( entity.getIndex() ); - const IndexType& index = entity.getIndex(); - matrixRow.setElement( 0, index, 1.0 ); - b[ index ] = Functions::FunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); - } - - - protected: - - Function function; - - //static_assert( Device::DeviceType == Function::Device::DeviceType ); -}; - - -template< typename Mesh, - typename Function > -std::ostream& operator << ( std::ostream& str, const MyMixedBoundaryConditions< Mesh, Function >& bc ) -{ - str << "MyMixed boundary conditions: vector = " << bc.getVector(); - return str; -} - -} // namespace Operators -} // namespace TNL - -#endif /* MYMIXEDBOUNDARYCONDITIONS_H_ */ diff --git a/src/Examples/inviscid-flow/3d/MyNeumannBoundaryConditions.h b/src/Examples/inviscid-flow/3d/MyNeumannBoundaryConditions.h deleted file mode 100644 index d56b8210f..000000000 --- a/src/Examples/inviscid-flow/3d/MyNeumannBoundaryConditions.h +++ /dev/null @@ -1,157 +0,0 @@ -//** coppied and changed -/*************************************************************************** - tnlMyNeumannBoundaryConditions.h - description - ------------------- - begin : Nov 17, 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 MYNEUMANNBOUNDARYCONDITIONS_H_ -#define MYNEUMANNBOUNDARYCONDITIONS_H_ - -#pragma once - -#include -#include -#include -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function = Functions::Analytic::Constant< Mesh::getMeshDimensions(), typename Mesh::RealType >, - int MeshEntitiesDimensions = Mesh::getMeshDimensions(), - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class MyNeumannBoundaryConditions -: public Operator< Mesh, - Functions::MeshBoundaryDomain, - MeshEntitiesDimensions, - MeshEntitiesDimensions, - Real, - Index > -{ - public: - - typedef Mesh MeshType; - typedef Function FunctionType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - - typedef Pointers::SharedPointer< Mesh > MeshPointer; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef typename MeshType::VertexType VertexType; - - static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< MeshType, FunctionType >::template setup< MeshPointer >( this->function, meshPointer, parameters, prefix ); - } - - void setFunction( const Function& function ) - { - this->function = function; - } - - Function& getFunction() - { - return this->function; - } - - const Function& getFunction() const - { - return this->function; - } - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighbourEntities = entity.getNeighbourEntities(); - typedef typename MeshType::Cell Cell; - int count = mesh.template getEntitiesCount< Cell >(); - count = std::sqrt(count); - if( entity.getCoordinates().x() == 0 ) - return u[ neighbourEntities.template getEntityIndex< 1, 0 >() ]; - else if( entity.getCoordinates().x() == count-1 ) - return u[ neighbourEntities.template getEntityIndex< -1, 0 >() ]; - else if( entity.getCoordinates().y() == 0 ) - return u[ neighbourEntities.template getEntityIndex< 0, 1 >() ]; - else return u[ neighbourEntities.template getEntityIndex< 0, -1 >() ]; - //tady se asi delaji okrajove podminky - //static_assert( EntityType::getDimensions() == MeshEntitiesDimensions, "Wrong mesh entity dimensions." ); - } - - template< typename EntityType > - __cuda_callable__ - IndexType getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 1; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - typename Matrix::MatrixRow matrixRow = matrix.getRow( entity.getIndex() ); - const IndexType& index = entity.getIndex(); - matrixRow.setElement( 0, index, 1.0 ); - b[ index ] = Functions::FunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); - } - - - protected: - - Function function; - - //static_assert( Device::DeviceType == Function::Device::DeviceType ); -}; - - -template< typename Mesh, - typename Function > -std::ostream& operator << ( std::ostream& str, const MyNeumannBoundaryConditions< Mesh, Function >& bc ) -{ - str << "MyNeumann boundary conditions: vector = " << bc.getVector(); - return str; -} - -} // namespace Operators -} // namespace TNL - -#endif /* MYNEUMANNBOUNDARYCONDITIONS_H_ */ diff --git a/src/Examples/inviscid-flow/3d/euler-cuda.cu b/src/Examples/inviscid-flow/3d/euler-cuda.cu deleted file mode 100644 index 4d76005cb..000000000 --- a/src/Examples/inviscid-flow/3d/euler-cuda.cu +++ /dev/null @@ -1 +0,0 @@ -#include "euler.h" diff --git a/src/Examples/inviscid-flow/3d/euler.cpp b/src/Examples/inviscid-flow/3d/euler.cpp deleted file mode 100644 index 4d76005cb..000000000 --- a/src/Examples/inviscid-flow/3d/euler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "euler.h" diff --git a/src/Examples/inviscid-flow/3d/euler.h b/src/Examples/inviscid-flow/3d/euler.h deleted file mode 100644 index 3160fe898..000000000 --- a/src/Examples/inviscid-flow/3d/euler.h +++ /dev/null @@ -1,169 +0,0 @@ -#include -#include -#include -#include -#include -#include "eulerProblem.h" -#include "LaxFridrichs3D.h" -#include "eulerRhs.h" -#include "eulerBuildConfigTag.h" -#include "MyMixedBoundaryConditions.h" -#include "MyNeumannBoundaryConditions.h" - -using namespace TNL; - -typedef eulerBuildConfigTag BuildConfig; - -/**** - * Uncoment the following (and comment the previous line) for the complete build. - * This will include support for all floating point precisions, all indexing types - * and more solvers. You may then choose between them from the command line. - * The compile time may, however, take tens of minutes or even several hours, - * esppecially if CUDA is enabled. Use this, if you want, only for the final build, - * not in the development phase. - */ -//typedef tnlDefaultConfigTag BuildConfig; - -template< typename ConfigTag >class eulerConfig -{ - public: - static void configSetup( Config::ConfigDescription & config ) - { - config.addDelimiter( "euler2D settings:" ); - config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "dirichlet"); - config.addEntryEnum< String >( "dirichlet" ); - config.addEntryEnum< String >( "neumann" ); - config.addEntryEnum< String >( "mymixed" ); - config.addEntryEnum< String >( "myneumann" ); - config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); - config.addEntry< double >( "NWU-density", "This sets a value of northwest up density." ); - config.addEntry< double >( "NWU-velocityX", "This sets a value of northwest up x velocity." ); - config.addEntry< double >( "NWU-velocityY", "This sets a value of northwest up y velocity." ); - config.addEntry< double >( "NWU-velocityZ", "This sets a value of northwest up z velocity." ); - config.addEntry< double >( "NWU-pressure", "This sets a value of northwest up pressure." ); - config.addEntry< double >( "SWU-density", "This sets a value of southwest up density." ); - config.addEntry< double >( "SWU-velocityX", "This sets a value of southwest up x velocity." ); - config.addEntry< double >( "SWU-velocityY", "This sets a value of southwest up y velocity." ); - config.addEntry< double >( "SWU-velocityZ", "This sets a value of southwest up z velocity." ); - config.addEntry< double >( "SWU-pressure", "This sets a value of southwest up pressure." ); - config.addEntry< double >( "NWD-density", "This sets a value of northwest down density." ); - config.addEntry< double >( "NWD-velocityX", "This sets a value of northwest down x velocity." ); - config.addEntry< double >( "NWD-velocityY", "This sets a value of northwest down y velocity." ); - config.addEntry< double >( "NWD-velocityZ", "This sets a value of northwest down z velocity." ); - config.addEntry< double >( "NWD-pressure", "This sets a value of northwest down pressure." ); - config.addEntry< double >( "SWD-density", "This sets a value of southwest down density." ); - config.addEntry< double >( "SWD-velocityX", "This sets a value of southwest down x velocity." ); - config.addEntry< double >( "SWD-velocityY", "This sets a value of southwest down y velocity." ); - config.addEntry< double >( "SWF-velocityZ", "This sets a value of southwest down z velocity." ); - config.addEntry< double >( "SWD-pressure", "This sets a value of southwest down pressure." ); - config.addEntry< double >( "riemann-border", "This sets a position of discontinuity cross." ); - config.addEntry< double >( "NEU-density", "This sets a value of northeast up density." ); - config.addEntry< double >( "NEU-velocityX", "This sets a value of northeast up x velocity." ); - config.addEntry< double >( "NEU-velocityY", "This sets a value of northeast up y velocity." ); - config.addEntry< double >( "NEU-velocityZ", "This sets a value of northeast up z velocity." ); - config.addEntry< double >( "NEU-pressure", "This sets a value of northeast up pressure." ); - config.addEntry< double >( "SEU-density", "This sets a value of southeast up density." ); - config.addEntry< double >( "SEU-velocityX", "This sets a value of southeast up x velocity." ); - config.addEntry< double >( "SEU-velocityY", "This sets a value of southeast up y velocity." ); - config.addEntry< double >( "SEU-velocityZ", "This sets a value of southeast up z velocity." ); - config.addEntry< double >( "SEU-pressure", "This sets a value of southeast up pressure." ); - config.addEntry< double >( "NED-density", "This sets a value of northeast down density." ); - config.addEntry< double >( "NED-velocityX", "This sets a value of northeast down x velocity." ); - config.addEntry< double >( "NED-velocityY", "This sets a value of northeast down y velocity." ); - config.addEntry< double >( "NED-velocityZ", "This sets a value of northeast down z velocity." ); - config.addEntry< double >( "NED-pressure", "This sets a value of northeast down pressure." ); - config.addEntry< double >( "SED-density", "This sets a value of southeast down density." ); - config.addEntry< double >( "SED-velocityX", "This sets a value of southeast down x velocity." ); - config.addEntry< double >( "SED-velocityY", "This sets a value of southeast down y velocity." ); - config.addEntry< double >( "SED-velocityZ", "This sets a value of southeast down z velocity." ); - config.addEntry< double >( "SED-pressure", "This sets a value of southeast down pressure." ); - config.addEntry< double >( "gamma", "This sets a value of gamma constant." ); - - /**** - * Add definition of your solver command line arguments. - */ - - } -}; - -template< typename Real, - typename Device, - typename Index, - typename MeshType, - typename ConfigTag, - typename SolverStarter > -class eulerSetter -{ - public: - - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - static bool run( const Config::ParameterContainer & parameters ) - { - enum { Dimensions = MeshType::getMeshDimensions() }; - typedef LaxFridrichs3D< MeshType, Real, Index > ApproximateOperator; - typedef eulerRhs< MeshType, Real > RightHandSide; - typedef Containers::StaticVector < MeshType::getMeshDimensions(), Real > Vertex; - - /**** - * Resolve the template arguments of your solver here. - * The following code is for the Dirichlet and the Neumann boundary conditions. - * Both can be constant or defined as descrete values of Vector. - */ - String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); - if( parameters.checkParameter( "boundary-conditions-constant" ) ) - { - typedef Functions::Analytic::Constant< Dimensions, Real > Constant; - if( boundaryConditionsType == "dirichlet" ) - { - typedef Operators::DirichletBoundaryConditions< MeshType, Constant, MeshType::getMeshDimensions(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - typedef Operators::NeumannBoundaryConditions< MeshType, Constant, Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - typedef Functions::MeshFunction< MeshType > MeshFunction; - if( boundaryConditionsType == "dirichlet" ) - { - typedef Operators::DirichletBoundaryConditions< MeshType, MeshFunction, MeshType::getMeshDimensions(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "mymixed" ) - { - typedef Operators::MyMixedBoundaryConditions< MeshType, MeshFunction, MeshType::getMeshDimensions(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "myneumann" ) - { - typedef Operators::MyNeumannBoundaryConditions< MeshType, MeshFunction, MeshType::getMeshDimensions(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "neumann" ) - { - typedef Operators::NeumannBoundaryConditions< MeshType, MeshFunction, Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - return true;} -}; - -int main( int argc, char* argv[] ) -{ - Solvers::Solver< eulerSetter, eulerConfig, BuildConfig > solver; - if( ! solver. run( argc, argv ) ) - return EXIT_FAILURE; - return EXIT_SUCCESS; -} diff --git a/src/Examples/inviscid-flow/3d/eulerBuildConfigTag.h b/src/Examples/inviscid-flow/3d/eulerBuildConfigTag.h deleted file mode 100644 index b3727450d..000000000 --- a/src/Examples/inviscid-flow/3d/eulerBuildConfigTag.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef eulerBUILDCONFIGTAG_H_ -#define eulerBUILDCONFIGTAG_H_ - -#include - -namespace TNL { - -class eulerBuildConfigTag{}; - -namespace Solvers { - -/**** - * Turn off support for float and long double. - */ -template<> struct ConfigTagReal< eulerBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct ConfigTagReal< eulerBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct ConfigTagIndex< eulerBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct ConfigTagIndex< eulerBuildConfigTag, long int >{ enum { enabled = false }; }; - -template< int Dimensions > struct ConfigTagDimensions< eulerBuildConfigTag, Dimensions >{ enum { enabled = ( Dimensions == 2 ) }; }; - -/**** - * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. - */ -template< int Dimensions, typename Real, typename Device, typename Index > - struct ConfigTagMesh< eulerBuildConfigTag, Meshes::Grid< Dimensions, Real, Device, Index > > - { enum { enabled = ConfigTagDimensions< eulerBuildConfigTag, Dimensions >::enabled && - ConfigTagReal< eulerBuildConfigTag, Real >::enabled && - ConfigTagDevice< eulerBuildConfigTag, Device >::enabled && - ConfigTagIndex< eulerBuildConfigTag, Index >::enabled }; }; - -/**** - * Please, chose your preferred time discretisation here. - */ -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; - -/**** - * Only the Runge-Kutta-Merson solver is enabled by default. - */ -template<> struct ConfigTagExplicitSolver< eulerBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; - -} // namespace Solvers -} // namespace TNL - - -#endif /* eulerBUILDCONFIGTAG_H_ */ diff --git a/src/Examples/inviscid-flow/3d/eulerProblem.h b/src/Examples/inviscid-flow/3d/eulerProblem.h deleted file mode 100644 index d2ff1fc10..000000000 --- a/src/Examples/inviscid-flow/3d/eulerProblem.h +++ /dev/null @@ -1,119 +0,0 @@ -#pragma once - -#include -#include - -using namespace TNL::Problems; - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > -class eulerProblem: - public PDEProblem< Mesh, - typename DifferentialOperator::RealType, - typename Mesh::DeviceType, - typename DifferentialOperator::IndexType > -{ - public: - - typedef typename DifferentialOperator::RealType RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef typename DifferentialOperator::IndexType IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - typedef Pointers::SharedPointer< DifferentialOperator > DifferentialOperatorPointer; - typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; - typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; - typedef PDEProblem< Mesh, RealType, DeviceType, IndexType > BaseType; - - using typename BaseType::MeshType; - using typename BaseType::MeshPointer; - using typename BaseType::DofVectorType; - using typename BaseType::DofVectorPointer; - using typename BaseType::MeshDependentDataType; - using typename BaseType::MeshDependentDataPointer; - - typedef typename DifferentialOperator::Continuity Continuity; - typedef typename DifferentialOperator::MomentumX MomentumX; - typedef typename DifferentialOperator::MomentumY MomentumY; - typedef typename DifferentialOperator::MomentumZ MomentumZ; - typedef typename DifferentialOperator::Energy Energy; - typedef typename DifferentialOperator::Velocity Velocity; - typedef typename DifferentialOperator::VelocityX VelocityX; - typedef typename DifferentialOperator::Pressure Pressure; - - static String getTypeStatic(); - - String getPrologHeader() const; - - void writeProlog( Logger& logger, - const Config::ParameterContainer& parameters ) const; - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ); - - bool setInitialCondition( const Config::ParameterContainer& parameters, - const MeshPointer& mesh, - DofVectorPointer& dofs, - MeshDependentDataPointer& meshDependentData ); - - template< typename Matrix > - bool setupLinearSystem( const MeshPointer& mesh, - Matrix& matrix ); - - bool makeSnapshot( const RealType& time, - const IndexType& step, - const MeshPointer& mesh, - DofVectorPointer& dofs, - MeshDependentDataPointer& meshDependentData ); - - IndexType getDofs( const MeshPointer& mesh ) const; - - void bindDofs( const MeshPointer& mesh, - DofVectorPointer& dofs ); - - void getExplicitRHS( const RealType& time, - const RealType& tau, - const MeshPointer& mesh, - DofVectorPointer& _u, - DofVectorPointer& _fu, - MeshDependentDataPointer& meshDependentData ); - - template< typename Matrix > - void assemblyLinearSystem( const RealType& time, - const RealType& tau, - const MeshPointer& mesh, - DofVectorPointer& dofs, - Matrix& matrix, - DofVectorPointer& rightHandSide, - MeshDependentDataPointer& meshDependentData ); - - bool postIterate( const RealType& time, - const RealType& tau, - const MeshPointer& mesh, - DofVectorPointer& dofs, - MeshDependentDataPointer& meshDependentData ); - - protected: - - DifferentialOperatorPointer differentialOperatorPointer; - BoundaryConditionPointer boundaryConditionPointer; - RightHandSidePointer rightHandSidePointer; - - MeshFunctionPointer uRho, uRhoVelocityX, uRhoVelocityY, uRhoVelocityZ, uEnergy; - MeshFunctionPointer fuRho, fuRhoVelocityX, fuRhoVelocityY, fuRhoVelocityZ, fuEnergy; - - MeshFunctionPointer pressure, velocity, velocityX, velocityY, velocityZ; - - RealType gamma; - -}; - -} // namespace TNL - -#include "eulerProblem_impl.h" - diff --git a/src/Examples/inviscid-flow/3d/eulerProblem_impl.h b/src/Examples/inviscid-flow/3d/eulerProblem_impl.h deleted file mode 100644 index b01979b87..000000000 --- a/src/Examples/inviscid-flow/3d/eulerProblem_impl.h +++ /dev/null @@ -1,579 +0,0 @@ -#include -#include -#include -#include -#include -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" -#include "EulerPressureGetter.h" -#include "Euler2DVelXGetter.h" -#include "EulerVelGetter.h" - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > -String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -getTypeStatic() -{ - return String( "eulerProblem< " ) + Mesh :: getTypeStatic() + " >"; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > -String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -getPrologHeader() const -{ - return String( "euler3D" ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const -{ - /**** - * Add data you want to have in the computation report (log) as follows: - * logger.writeParameter< double >( "Parameter description", parameter ); - */ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix ) -{ - if( //! this->boundaryConditionPointer->setup( meshPointer, parameters, prefix + "boundary-conditions-" ) || - ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) - return false; - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > -typename eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >::IndexType -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -getDofs( const MeshPointer& mesh ) const -{ - /**** - * Return number of DOFs (degrees of freedom) i.e. number - * of unknowns to be resolved by the main solver. - */ - return 5*mesh->template getEntitiesCount< typename MeshType::Cell >(); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -bindDofs( const MeshPointer& mesh, - DofVectorPointer& dofVector ) -{ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -setInitialCondition( const Config::ParameterContainer& parameters, - const MeshPointer& mesh, - DofVectorPointer& dofs, - MeshDependentDataPointer& meshDependentData ) -{ - typedef typename MeshType::Cell Cell; - gamma = parameters.getParameter< RealType >( "gamma" ); - RealType rhoNWU = parameters.getParameter< RealType >( "NWU-density" ); - RealType velNWUX = parameters.getParameter< RealType >( "NWU-velocityX" ); - RealType velNWUY = parameters.getParameter< RealType >( "NWU-velocityY" ); - RealType velNWUZ = parameters.getParameter< RealType >( "NWU-velocityZ" ); - RealType preNWU = parameters.getParameter< RealType >( "NWU-pressure" ); - //RealType eNWU = ( preNWU / ( rhoNWU * (gamma - 1) ) ); - RealType eNWU = ( preNWU / (gamma - 1) ) + 0.5 * rhoNWU * (std::pow(velNWUX,2)+std::pow(velNWUY,2)+std::pow(velNWUZ,2)); - RealType rhoSWU = parameters.getParameter< RealType >( "SWU-density" ); - RealType velSWUX = parameters.getParameter< RealType >( "SWU-velocityX" ); - RealType velSWUY = parameters.getParameter< RealType >( "SWU-velocityY" ); - RealType velSWUZ = parameters.getParameter< RealType >( "SWU-velocityZ" ); - RealType preSWU = parameters.getParameter< RealType >( "SWU-pressure" ); - //RealType eSWU = ( preSWU / ( rhoSWU * (gamma - 1) ) ); - RealType eSWU = ( preSWU / (gamma - 1) ) + 0.5 * rhoSWU * (std::pow(velSWUX,2)+std::pow(velSWUY,2)+std::pow(velSWUZ,2)); - RealType rhoNWD = parameters.getParameter< RealType >( "NWD-density" ); - RealType velNWDX = parameters.getParameter< RealType >( "NWD-velocityX" ); - RealType velNWDY = parameters.getParameter< RealType >( "NWD-velocityY" ); - RealType velNWDZ = parameters.getParameter< RealType >( "NWD-velocityZ" ); - RealType preNWD = parameters.getParameter< RealType >( "NWD-pressure" ); - //RealType eNWD = ( preNWD / ( rhoNWD * (gamma - 1) ) ); - RealType eNWD = ( preNWD / (gamma - 1) ) + 0.5 * rhoNWD * (std::pow(velNWDX,2)+std::pow(velNWDY,2)+std::pow(velNWDZ,2)); - RealType rhoSWD = parameters.getParameter< RealType >( "SWD-density" ); - RealType velSWDX = parameters.getParameter< RealType >( "SWD-velocityX" ); - RealType velSWDY = parameters.getParameter< RealType >( "SWD-velocityY" ); - RealType velSWDZ = parameters.getParameter< RealType >( "SWD-velocityZ" ); - RealType preSWD = parameters.getParameter< RealType >( "SWD-pressure" ); - //RealType eSWD = ( preSWD / ( rhoSWD * (gamma - 1) ) ); - RealType eSWD = ( preSWD / (gamma - 1) ) + 0.5 * rhoSWD * (std::pow(velSWDX,2)+std::pow(velSWDY,2)+std::pow(velSWDZ,2)); - RealType rhoNEU = parameters.getParameter< RealType >( "NEU-density" ); - RealType velNEUX = parameters.getParameter< RealType >( "NEU-velocityX" ); - RealType velNEUY = parameters.getParameter< RealType >( "NEU-velocityY" ); - RealType velNEUZ = parameters.getParameter< RealType >( "NEU-velocityZ" ); - RealType preNEU = parameters.getParameter< RealType >( "NEU-pressure" ); - //RealType eNEU = ( preNEU / ( rhoNEU * (gamma - 1) ) ); - RealType eNEU = ( preNEU / (gamma - 1) ) + 0.5 * rhoNEU * (std::pow(velNEUX,2)+std::pow(velNEUY,2)+std::pow(velNEUZ,2)); - RealType rhoSEU = parameters.getParameter< RealType >( "SEU-density" ); - RealType velSEUX = parameters.getParameter< RealType >( "SEU-velocityX" ); - RealType velSEUY = parameters.getParameter< RealType >( "SEU-velocityY" ); - RealType velSEUZ = parameters.getParameter< RealType >( "SEU-velocityZ" ); - RealType preSEU = parameters.getParameter< RealType >( "SEU-pressure" ); - //RealType eSEU = ( preSEU / ( rhoSEU * (gamma - 1) ) ); - RealType eSEU = ( preSEU / (gamma - 1) ) + 0.5 * rhoSEU * (std::pow(velSEUX,2)+std::pow(velSEUY,2)+std::pow(velSEUZ,2)); - RealType rhoNED = parameters.getParameter< RealType >( "NED-density" ); - RealType velNEDX = parameters.getParameter< RealType >( "NED-velocityX" ); - RealType velNEDY = parameters.getParameter< RealType >( "NED-velocityY" ); - RealType velNEDZ = parameters.getParameter< RealType >( "NED-velocityZ" ); - RealType preNED = parameters.getParameter< RealType >( "NED-pressure" ); - //RealType eNED = ( preNED / ( rhoNED * (gamma - 1) ) ); - RealType eNED = ( preNED / (gamma - 1) ) + 0.5 * rhoNED * (std::pow(velNEDX,2)+std::pow(velNEDY,2)+std::pow(velNEDZ,2)); - RealType rhoSED = parameters.getParameter< RealType >( "SED-density" ); - RealType velSEDX = parameters.getParameter< RealType >( "SED-velocityX" ); - RealType velSEDY = parameters.getParameter< RealType >( "SED-velocityY" ); - RealType velSEDZ = parameters.getParameter< RealType >( "SED-velocityZ" ); - RealType preSED = parameters.getParameter< RealType >( "SED-pressure" ); - //RealType eSED = ( preSED / ( rhoSED * (gamma - 1) ) ); - RealType eSED = ( preSED / (gamma - 1) ) + 0.5 * rhoSED * (std::pow(velSEDX,2)+std::pow(velSEDY,2)+std::pow(velSEDZ,2)); - RealType x0 = parameters.getParameter< RealType >( "riemann-border" ); - int size = mesh->template getEntitiesCount< Cell >(); - uRho->bind(mesh, dofs, 0); - uRhoVelocityX->bind(mesh, dofs, size); - uRhoVelocityY->bind(mesh, dofs, 2*size); - uRhoVelocityZ->bind(mesh, dofs, 3*size); - uEnergy->bind(mesh, dofs, 4*size); - Containers::Vector< RealType, DeviceType, IndexType > data; - data.setSize(5*size); - pressure->bind(mesh, data, 0); - velocity->bind(mesh, data, size); - velocityX->bind(mesh, data, 2*size); - velocityY->bind(mesh, data, 3*size); - velocityZ->bind(mesh, data, 4*size); - int count = std::pow(size, (1.0/3.0)); - for(IndexType i = 0; i < count; i++) - for(IndexType j = 0; j < count; j++) - for(IndexType k = 0; k < count; k++) - if ((i <= x0 * count)&&(j <= x0 * count)&&(k <= x0 * count) ) - { - (* uRho)[i*std::pow(count,2)+j*count+k] = rhoSWD; - (* uRhoVelocityX)[i*std::pow(count,2)+j*count+k] = rhoSWD * velSWDX; - (* uRhoVelocityY)[i*std::pow(count,2)+j*count+k] = rhoSWD * velSWDY; - (* uRhoVelocityZ)[i*std::pow(count,2)+j*count+k] = rhoSWD * velSWDZ; - (* uEnergy)[i*std::pow(count,2)+j*count+k] = eSWD; - (* velocity)[i*std::pow(count,2)+j*count+k] = std::sqrt(std::pow(velSWDX,2)+std::pow(velSWDY,2)+std::pow(velSWDZ,2)); - (* velocityX)[i*std::pow(count,2)+j*count+k] = velSWDX; - (* velocityY)[i*std::pow(count,2)+j*count+k] = velSWDY; - (* velocityZ)[i*std::pow(count,2)+j*count+k] = velSWDZ; - (* pressure)[i*std::pow(count,2)+j*count+k] = preSWD; - } - else - if ((i <= x0 * count)&&(j <= x0 * count)&&(k > x0 * count) ) - { - (* uRho)[i*std::pow(count,2)+j*count+k] = rhoSED; - (* uRhoVelocityX)[i*std::pow(count,2)+j*count+k] = rhoSED * velSEDX; - (* uRhoVelocityY)[i*std::pow(count,2)+j*count+k] = rhoSED * velSEDY; - (* uRhoVelocityZ)[i*std::pow(count,2)+j*count+k] = rhoSED * velSEDZ; - (* uEnergy)[i*std::pow(count,2)+j*count+k] = eSED; - (* velocity)[i*std::pow(count,2)+j*count+k] = std::sqrt(std::pow(velSEDX,2)+std::pow(velSEDY,2)+std::pow(velSEDZ,2)); - (* velocityX)[i*std::pow(count,2)+j*count+k] = velSEDX; - (* velocityY)[i*std::pow(count,2)+j*count+k] = velSEDY; - (* velocityZ)[i*std::pow(count,2)+j*count+k] = velSEDZ; - (* pressure)[i*std::pow(count,2)+j*count+k] = preSED; - } - else - if ((i <= x0 * count)&&(j > x0 * count)&&(k <= x0 * count) ) - { - (* uRho)[i*std::pow(count,2)+j*count+k] = rhoNWD; - (* uRhoVelocityX)[i*std::pow(count,2)+j*count+k] = rhoNWD * velNWDX; - (* uRhoVelocityY)[i*std::pow(count,2)+j*count+k] = rhoNWD * velNWDY; - (* uRhoVelocityZ)[i*std::pow(count,2)+j*count+k] = rhoNWD * velNWDZ; - (* uEnergy)[i*std::pow(count,2)+j*count+k] = eNWD; - (* velocity)[i*std::pow(count,2)+j*count+k] = std::sqrt(std::pow(velNWDX,2)+std::pow(velNWDY,2)+std::pow(velNWDZ,2)); - (* velocityX)[i*std::pow(count,2)+j*count+k] = velNWDX; - (* velocityY)[i*std::pow(count,2)+j*count+k] = velNWDY; - (* velocityZ)[i*std::pow(count,2)+j*count+k] = velNWDZ; - (* pressure)[i*std::pow(count,2)+j*count+k] = preNWD; - } - else - if ((i <= x0 * count)&&(j > x0 * count)&&(k > x0 * count) ) - { - (* uRho)[i*std::pow(count,2)+j*count+k] = rhoNED; - (* uRhoVelocityX)[i*std::pow(count,2)+j*count+k] = rhoNED * velNEDX; - (* uRhoVelocityY)[i*std::pow(count,2)+j*count+k] = rhoNED * velNEDY; - (* uRhoVelocityZ)[i*std::pow(count,2)+j*count+k] = rhoNED * velNEDZ; - (* uEnergy)[i*std::pow(count,2)+j*count+k] = eNED; - (* velocity)[i*std::pow(count,2)+j*count+k] = std::sqrt(std::pow(velNEDX,2)+std::pow(velNEDY,2)+std::pow(velNEDZ,2)); - (* velocityX)[i*std::pow(count,2)+j*count+k] = velNEDX; - (* velocityY)[i*std::pow(count,2)+j*count+k] = velNEDY; - (* velocityZ)[i*std::pow(count,2)+j*count+k] = velNEDZ; - (* pressure)[i*std::pow(count,2)+j*count+k] = preNED; - } - else - if ((i > x0 * count)&&(j <= x0 * count)&&(k <= x0 * count) ) - { - (* uRho)[i*std::pow(count,2)+j*count+k] = rhoSWU; - (* uRhoVelocityX)[i*std::pow(count,2)+j*count+k] = rhoSWU * velSWUX; - (* uRhoVelocityY)[i*std::pow(count,2)+j*count+k] = rhoSWU * velSWUY; - (* uRhoVelocityZ)[i*std::pow(count,2)+j*count+k] = rhoSWU * velSWUZ; - (* uEnergy)[i*std::pow(count,2)+j*count+k] = eSWU; - (* velocity)[i*std::pow(count,2)+j*count+k] = std::sqrt(std::pow(velSWUX,2)+std::pow(velSWUY,2)+std::pow(velSWUZ,2)); - (* velocityX)[i*std::pow(count,2)+j*count+k] = velSWUX; - (* velocityY)[i*std::pow(count,2)+j*count+k] = velSWUY; - (* velocityZ)[i*std::pow(count,2)+j*count+k] = velSWUZ; - (* pressure)[i*std::pow(count,2)+j*count+k] = preSWU; - } - else - if ((i > x0 * count)&&(j <= x0 * count)&&(k > x0 * count) ) - { - (* uRho)[i*std::pow(count,2)+j*count+k] = rhoSEU; - (* uRhoVelocityX)[i*std::pow(count,2)+j*count+k] = rhoSEU * velSEUX; - (* uRhoVelocityY)[i*std::pow(count,2)+j*count+k] = rhoSEU * velSEUY; - (* uRhoVelocityZ)[i*std::pow(count,2)+j*count+k] = rhoSEU * velSEUZ; - (* uEnergy)[i*std::pow(count,2)+j*count+k] = eSEU; - (* velocity)[i*std::pow(count,2)+j*count+k] = std::sqrt(std::pow(velSEUX,2)+std::pow(velSEUY,2)+std::pow(velSEUZ,2)); - (* velocityX)[i*std::pow(count,2)+j*count+k] = velSEUX; - (* velocityY)[i*std::pow(count,2)+j*count+k] = velSEUY; - (* velocityZ)[i*std::pow(count,2)+j*count+k] = velSEUZ; - (* pressure)[i*std::pow(count,2)+j*count+k] = preSEU; - } - else - if ((i > x0 * count)&&(j > x0 * count)&&(k <= x0 * count) ) - { - (* uRho)[i*std::pow(count,2)+j*count+k] = rhoNWU; - (* uRhoVelocityX)[i*std::pow(count,2)+j*count+k] = rhoNWU * velNWUX; - (* uRhoVelocityY)[i*std::pow(count,2)+j*count+k] = rhoNWU * velNWUY; - (* uRhoVelocityZ)[i*std::pow(count,2)+j*count+k] = rhoNWU * velNWUZ; - (* uEnergy)[i*std::pow(count,2)+j*count+k] = eNWU; - (* velocity)[i*std::pow(count,2)+j*count+k] = std::sqrt(std::pow(velNWUX,2)+std::pow(velNWUY,2)+std::pow(velNWUZ,2)); - (* velocityX)[i*std::pow(count,2)+j*count+k] = velNWUX; - (* velocityY)[i*std::pow(count,2)+j*count+k] = velNWUY; - (* velocityZ)[i*std::pow(count,2)+j*count+k] = velNWUZ; - (* pressure)[i*std::pow(count,2)+j*count+k] = preNWU; - } - else - if ((i > x0 * count)&&(j > x0 * count)&&(k > x0 * count) ) - { - (* uRho)[i*std::pow(count,2)+j*count+k] = rhoNEU; - (* uRhoVelocityX)[i*std::pow(count,2)+j*count+k] = rhoNEU * velNEUX; - (* uRhoVelocityY)[i*std::pow(count,2)+j*count+k] = rhoNEU * velNEUY; - (* uRhoVelocityZ)[i*std::pow(count,2)+j*count+k] = rhoNEU * velNEUZ; - (* uEnergy)[i*std::pow(count,2)+j*count+k] = eNEU; - (* velocity)[i*std::pow(count,2)+j*count+k] = std::sqrt(std::pow(velNEUX,2)+std::pow(velNEUY,2)+std::pow(velNEUZ,2)); - (* velocityX)[i*std::pow(count,2)+j*count+k] = velNEUX; - (* velocityY)[i*std::pow(count,2)+j*count+k] = velNEUY; - (* velocityZ)[i*std::pow(count,2)+j*count+k] = velNEUZ; - (* pressure)[i*std::pow(count,2)+j*count+k] = preNEU; - }; - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > - template< typename Matrix > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -setupLinearSystem( const MeshPointer& mesh, - Matrix& matrix ) -{ -/* const IndexType dofs = this->getDofs( mesh ); - typedef typename Matrix::CompressedRowsLengthsVector CompressedRowsLengthsVectorType; - CompressedRowsLengthsVectorType rowLengths; - if( ! rowLengths.setSize( dofs ) ) - return false; - MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowsLengthsVectorType > matrixSetter; - matrixSetter.template getCompressedRowsLengths< typename Mesh::Cell >( mesh, - differentialOperator, - boundaryCondition, - rowLengths ); - matrix.setDimensions( dofs, dofs ); - if( ! matrix.setCompressedRowsLengths( rowLengths ) ) - return false;*/ - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -makeSnapshot( const RealType& time, - const IndexType& step, - const MeshPointer& mesh, - DofVectorPointer& dofs, - MeshDependentDataPointer& meshDependentData ) -{ - std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; - FileName fileName; - fileName.setExtension( "tnl" ); - fileName.setIndex( step ); - fileName.setFileNameBase( "rho-" ); - if( ! uRho->save( fileName.getFileName() ) ) - return false; - fileName.setFileNameBase( "rhoVelX-" ); - if( ! uRhoVelocityX->save( fileName.getFileName() ) ) - return false; - fileName.setFileNameBase( "rhoVelY-" ); - if( ! uRhoVelocityY->save( fileName.getFileName() ) ) - return false; - fileName.setFileNameBase( "rhoVelZ-" ); - if( ! uRhoVelocityY->save( fileName.getFileName() ) ) - return false; - fileName.setFileNameBase( "energy-" ); - if( ! uEnergy->save( fileName.getFileName() ) ) - return false; - fileName.setFileNameBase( "velocityX-" ); - if( ! velocityX->save( fileName.getFileName() ) ) - return false; - fileName.setFileNameBase( "velocityY-" ); - if( ! velocityY->save( fileName.getFileName() ) ) - return false; - fileName.setFileNameBase( "velocityZ-" ); - if( ! velocityY->save( fileName.getFileName() ) ) - return false; - fileName.setFileNameBase( "velocity-" ); - if( ! velocity->save( fileName.getFileName() ) ) - return false; - fileName.setFileNameBase( "pressue-" ); - if( ! pressure->save( fileName.getFileName() ) ) - return false; - - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -getExplicitRHS( const RealType& time, - const RealType& tau, - const MeshPointer& mesh, - DofVectorPointer& _u, - DofVectorPointer& _fu, - MeshDependentDataPointer& meshDependentData ) -{ - typedef typename MeshType::Cell Cell; - int count = mesh->template getEntitiesCount< Cell >(); - fuRho->bind( mesh, _fu, 0 ); - fuRhoVelocityX->bind( mesh, _fu, count ); - fuRhoVelocityY->bind( mesh, _fu, 2*count ); - fuRhoVelocityZ->bind( mesh, _fu, 3*count ); - fuEnergy->bind( mesh, _fu, 4*count ); - SharedPointer< Continuity > lF3DContinuity; - SharedPointer< MomentumX > lF3DMomentumX; - SharedPointer< MomentumY > lF3DMomentumY; - SharedPointer< MomentumZ > lF3DMomentumZ; - SharedPointer< Energy > lF3DEnergy; - - this->bindDofs( mesh, _u ); - //rho - lF3DContinuity->setTau(tau); - lF3DContinuity->setVelocityX( *velocityX ); - lF3DContinuity->setVelocityY( *velocityY ); - lF3DContinuity->setVelocityZ( *velocityZ ); - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, Continuity, BoundaryCondition, RightHandSide > explicitUpdaterContinuity; - explicitUpdaterContinuity.template update< typename Mesh::Cell >( time, - mesh, - lF3DContinuity, - this->boundaryConditionPointer, - this->rightHandSidePointer, - uRho, - fuRho ); - - //rhoVelocityX - lF3DMomentumX->setTau(tau); - lF3DMomentumX->setVelocityX( *velocityX ); - lF3DMomentumX->setVelocityY( *velocityY ); - lF3DMomentumX->setVelocityZ( *velocityZ ); - lF3DMomentumX->setPressure( *pressure ); - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumX, BoundaryCondition, RightHandSide > explicitUpdaterMomentumX; - explicitUpdaterMomentumX.template update< typename Mesh::Cell >( time, - mesh, - lF3DMomentumX, - this->boundaryConditionPointer, - this->rightHandSidePointer, - uRhoVelocityX, - fuRhoVelocityX ); - - //rhoVelocityY - lF3DMomentumY->setTau(tau); - lF3DMomentumY->setVelocityX( *velocityX ); - lF3DMomentumY->setVelocityY( *velocityY ); - lF3DMomentumY->setVelocityZ( *velocityZ ); - lF3DMomentumY->setPressure( *pressure ); - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumY, BoundaryCondition, RightHandSide > explicitUpdaterMomentumY; - explicitUpdaterMomentumY.template update< typename Mesh::Cell >( time, - mesh, - lF3DMomentumY, - this->boundaryConditionPointer, - this->rightHandSidePointer, - uRhoVelocityY, - fuRhoVelocityY ); - - //rhoVelocityZ - lF3DMomentumZ->setTau(tau); - lF3DMomentumZ->setVelocityX( *velocityX ); - lF3DMomentumZ->setVelocityY( *velocityY ); - lF3DMomentumZ->setVelocityZ( *velocityZ ); - lF3DMomentumZ->setPressure( *pressure ); - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZ, BoundaryCondition, RightHandSide > explicitUpdaterMomentumZ; - explicitUpdaterMomentumZ.template update< typename Mesh::Cell >( time, - mesh, - lF3DMomentumZ, - this->boundaryConditionPointer, - this->rightHandSidePointer, - uRhoVelocityZ, - fuRhoVelocityZ ); - - //energy - lF3DEnergy->setTau(tau); - lF3DEnergy->setVelocityX( *velocityX ); - lF3DEnergy->setVelocityY( *velocityY ); - lF3DEnergy->setVelocityZ( *velocityZ ); - lF3DEnergy->setPressure( *pressure ); - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, Energy, BoundaryCondition, RightHandSide > explicitUpdaterEnergy; - explicitUpdaterEnergy.template update< typename Mesh::Cell >( time, - mesh, - lF3DEnergy, - this->boundaryConditionPointer, - this->rightHandSidePointer, - uEnergy, - fuEnergy ); - -/* -cout << "rho " << uRho.getData() << endl; -getchar(); -cout << "rhoVelX " << uRhoVelocityX.getData() << endl; -getchar(); -cout << "rhoVelY " << uRhoVelocityY.getData() << endl; -getchar(); -cout << "Energy " << uEnergy.getData() << endl; -getchar(); -cout << "velocity " << velocity.getData() << endl; -getchar(); -cout << "velocityX " << velocityX.getData() << endl; -getchar(); -cout << "velocityY " << velocityY.getData() << endl; -getchar(); -cout << "pressure " << pressure.getData() << endl; -getchar(); -*/ - - -/* - BoundaryConditionsSetter< MeshFunctionType, BoundaryCondition > boundaryConditionsSetter; - boundaryConditionsSetter.template apply< typename Mesh::Cell >( - this->boundaryCondition, - time + tau, - u );*/ - } - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > - template< typename Matrix > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -assemblyLinearSystem( const RealType& time, - const RealType& tau, - const MeshPointer& mesh, - DofVectorPointer& _u, - Matrix& matrix, - DofVectorPointer& b, - MeshDependentDataPointer& meshDependentData ) -{ -/* LinearSystemAssembler< Mesh, - MeshFunctionType, - DifferentialOperator, - BoundaryCondition, - RightHandSide, - BackwardTimeDiscretisation, - Matrix, - DofVectorType > systemAssembler; - - MeshFunction< Mesh > u( mesh, _u ); - systemAssembler.template assembly< typename Mesh::Cell >( time, - tau, - mesh, - this->differentialOperator, - this->boundaryCondition, - this->rightHandSide, - u, - matrix, - b );*/ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename DifferentialOperator > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, DifferentialOperator >:: -postIterate( const RealType& time, - const RealType& tau, - const MeshPointer& mesh, - DofVectorPointer& dofs, - MeshDependentDataPointer& meshDependentData ) -{ - - //velocityX - this->velocityX->setMesh( mesh ); - VelocityX velocityXGetter( *uRho, *uRhoVelocityX ); - *this->velocityX = velocityXGetter; - - //velocityY - this->velocityY->setMesh( mesh ); - VelocityX velocityYGetter( *uRho, *uRhoVelocityY ); - *this->velocityY = velocityYGetter; - - //velocityY - this->velocityZ->setMesh( mesh ); - VelocityX velocityZGetter( *uRho, *uRhoVelocityZ ); - *this->velocityZ = velocityZGetter; - - //velocity - this->velocity->setMesh( mesh ); - Velocity velocityGetter( *uRho, *uRhoVelocityX, *uRhoVelocityY, *uRhoVelocityZ); - *this->velocity = velocityGetter; - - //pressure - this->pressure->setMesh( mesh ); - Pressure pressureGetter( *uRho, *uRhoVelocityX, *uRhoVelocityY, *uRhoVelocityZ, *uEnergy, gamma ); - *this->pressure = pressureGetter; - - return true; -} - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow/3d/eulerRhs.h b/src/Examples/inviscid-flow/3d/eulerRhs.h deleted file mode 100644 index 1b46dc831..000000000 --- a/src/Examples/inviscid-flow/3d/eulerRhs.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef eulerRHS_H_ -#define eulerRHS_H_ - -#include - -namespace TNL { - -template< typename Mesh, typename Real >class eulerRhs - : public Functions::Domain< Mesh::meshDimensions, Functions::MeshDomain > - { - public: - - typedef Mesh MeshType; - typedef Real RealType; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; - } - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const Real& time = 0.0 ) const - { - typedef typename MeshEntity::MeshType::VertexType VertexType; - VertexType v = entity.getCenter(); - return 0.0; - } -}; - -} //namespace TNL - -#endif /* eulerRHS_H_ */ diff --git a/src/Examples/inviscid-flow/3d/run-euler b/src/Examples/inviscid-flow/3d/run-euler deleted file mode 100644 index f68b98a84..000000000 --- a/src/Examples/inviscid-flow/3d/run-euler +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 2 \ - --origin-x 0.0 \ - --origin-y 0.0 \ - --proportions-x 1.0 \ - --proportions-y 1.0 \ - --size-x 100 \ - --size-y 100 - -tnl-init --test-function sin-wave \ - --output-file init.tnl -./euler --time-discretisation explicit \ - --boundary-conditions-constant 0 \ - --discrete-solver merson \ - --snapshot-period 0.01 \ - --final-time 1.0 - -tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/inviscid-flow/3d/tnl-run-euler-2d b/src/Examples/inviscid-flow/3d/tnl-run-euler-2d deleted file mode 100644 index 5af33a1a7..000000000 --- a/src/Examples/inviscid-flow/3d/tnl-run-euler-2d +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 2 \ - --origin-x 0.0 \ - --origin-y 0.0 \ - --proportions-x 1.0 \ - --proportions-y 1.0 \ - --size-x 100 \ - --size-y 100 - -#tnl-init --test-function sin-wave \ -# --output-file init.tnl -# --boundary-conditions-type neumann \ -# --boundary-conditions-constant 0 \ - -tnl-euler-2d-dbg --time-discretisation explicit \ - --time-step 1.0e-3 \ - --boundary-conditions-type mymixed \ - --discrete-solver euler \ - --snapshot-period 0.1 \ - --final-time 1.0 \ - --left-density 1.0 \ - --left-velocityX 0.75 \ - --left-velocityY 0.75 \ - --left-pressure 1.0 \ - --right-density 0.125 \ - --right-velocityX 0 \ - --right-velocityY 0 \ - --right-pressure 0.1 \ - --gamma 1.4 \ - --riemann-border 0.3 \ - -tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/inviscid-flow/CMakeLists.txt b/src/Examples/inviscid-flow/CMakeLists.txt deleted file mode 100644 index dbfe2024d..000000000 --- a/src/Examples/inviscid-flow/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -set( tnl_inviscid_flow_HEADERS - CompressibleConservativeVariables.h ) - -set( tnl_inviscid_flow_SOURCES - euler.cpp - euler.cu ) - -IF( BUILD_CUDA ) - CUDA_ADD_EXECUTABLE(tnl-euler euler.cu) - target_link_libraries (tnl-euler ${CUSPARSE_LIBRARY} ) -ELSE( BUILD_CUDA ) - ADD_EXECUTABLE(tnl-euler euler.cpp) -ENDIF( BUILD_CUDA ) - - -INSTALL( TARGETS tnl-euler - RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) - -INSTALL( FILES run-euler - ${tnl_inviscid_flow_SOURCES} - DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/inviscid-flow ) - diff --git a/src/Examples/inviscid-flow/RiemannProblemInitialCondition.h b/src/Examples/inviscid-flow/RiemannProblemInitialCondition.h deleted file mode 100644 index a3d54c747..000000000 --- a/src/Examples/inviscid-flow/RiemannProblemInitialCondition.h +++ /dev/null @@ -1,1417 +0,0 @@ -/*************************************************************************** - RiemannProblemInitialCondition.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -template -class RiemannProblemInitialConditionSetter -{ - -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 1,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 2,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template< typename Mesh > -class RiemannProblemInitialCondition -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; - - RiemannProblemInitialCondition() - : discontinuityPlacement( 0.5 ), - leftDensity( 1.0 ), rightDensity( 1.0 ), - leftVelocity( -2.0 ), rightVelocity( 2.0 ), - leftPressure( 0.4 ), rightPressure( 0.4 ), - gamma( 1.67 ){} - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "discontinuity-placement-0", "x-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-1", "y-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-2", "z-coordinate of the discontinuity placement.", 0.5 ); -/* - config.addEntry< double >( prefix + "left-density", "Density on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-density", "Density on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-velocity-0", "x-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-1", "y-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-2", "z-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-velocity-0", "x-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-1", "y-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-2", "z-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-pressure", "Pressure on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-pressure", "Pressure on the right side of the discontinuity.", 0.0 ); -*/ - config.addEntry< double >( prefix + "NWU-density", "This sets a value of northwest up density.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-0", "This sets a value of northwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-1", "This sets a value of northwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-2", "This sets a value of northwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-pressure", "This sets a value of northwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWU-density", "This sets a value of southwest up density.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-0", "This sets a value of southwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-1", "This sets a value of southwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-2", "This sets a value of southwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-pressure", "This sets a value of southwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NWD-density", "This sets a value of northwest down density.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-0", "This sets a value of northwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-1", "This sets a value of northwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-2", "This sets a value of northwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-pressure", "This sets a value of northwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWD-density", "This sets a value of southwest down density.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-0", "This sets a value of southwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-1", "This sets a value of southwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-2", "This sets a value of southwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-pressure", "This sets a value of southwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "NEU-density", "This sets a value of northeast up density.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-0", "This sets a value of northeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-1", "This sets a value of northeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-2", "This sets a value of northeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-pressure", "This sets a value of northeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SEU-density", "This sets a value of southeast up density.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-0", "This sets a value of southeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-1", "This sets a value of southeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-2", "This sets a value of southeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-pressure", "This sets a value of southeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NED-density", "This sets a value of northeast down density.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-0", "This sets a value of northeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-1", "This sets a value of northeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-2", "This sets a value of northeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-pressure", "This sets a value of northeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SED-density", "This sets a value of southeast down density.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-0", "This sets a value of southeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-1", "This sets a value of southeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-2", "This sets a value of southeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-pressure", "This sets a value of southeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "gamma", "Gamma in the ideal gas state equation.", 1.4 ); - - config.addEntry< String >( prefix + "initial", " One of predefined initial condition.", "none"); - config.addEntryEnum< String >( "none" ); - config.addEntryEnum< String >( "1D_2" ); - config.addEntryEnum< String >( "1D_3a" ); - config.addEntryEnum< String >( "1D_4" ); - config.addEntryEnum< String >( "1D_5" ); - config.addEntryEnum< String >( "1D_6" ); - config.addEntryEnum< String >( "1D_Noh" ); - config.addEntryEnum< String >( "1D_peak" ); - config.addEntryEnum< String >( "2D_3" ); - config.addEntryEnum< String >( "2D_4" ); - config.addEntryEnum< String >( "2D_6" ); - config.addEntryEnum< String >( "2D_12" ); - config.addEntryEnum< String >( "2D_15" ); - config.addEntryEnum< String >( "2D_17" ); - } - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - String initial = parameters.getParameter< String >( prefix + "initial" ); - if(initial == prefix + "none") - { - this->discontinuityPlacement.setup( parameters, prefix + "discontinuity-placement-" ); - this->gamma = parameters.getParameter< double >( prefix + "gamma" ); -/* - this->leftVelocity.setup( parameters, prefix + "left-velocity-" ); - this->rightVelocity.setup( parameters, prefix + "right-velocity-" ); - this->leftDensity = parameters.getParameter< double >( prefix + "left-density" ); - this->rightDensity = parameters.getParameter< double >( prefix + "right-density" ); - this->leftPressure = parameters.getParameter< double >( prefix + "left-pressure" ); - this->rightPressure = parameters.getParameter< double >( prefix + "right-pressure" ); -*/ - - this->NWUDensity = parameters.getParameter< RealType >( prefix + "NWU-density" ); - this->NWUVelocity.setup( parameters, prefix + "NWU-velocity-" ); - this->NWUPressure = parameters.getParameter< RealType >( prefix + "NWU-pressure" ); - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); - this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); - this->SWUPressure = parameters.getParameter< RealType >( prefix + "SWU-pressure" ); - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); - this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); - this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); - this->SWUEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); - this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); - this->SWDPressure = parameters.getParameter< RealType >( prefix + "SWD-pressure" ); - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); - this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); - this->NEUPressure = parameters.getParameter< RealType >( prefix + "NEU-pressure" ); - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); - this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); - this->SEUPressure = parameters.getParameter< RealType >( prefix + "SEU-pressure" ); - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); - this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); - this->NEDPressure = parameters.getParameter< RealType >( prefix + "NED-pressure" ); - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); - this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); - this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - - } - if(initial == prefix + "1D_2") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -2.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_3a") - predefinedInitialCondition( 1.4, 0.8, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1000.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.01, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -19.59745, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -19.59745, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_4") - predefinedInitialCondition( 1.666, 0.4, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 5.99924, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 5.99242, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 460.894, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 46.095, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 19.5975, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -6.19633, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_5") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_6") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.1, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_Noh") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.000001, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.000001, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_peak") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 0.12612, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 6.5915, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 782.929, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 3.15449, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 8.90470, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.26542, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_3") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5323, 0.138, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.5, 0.5323, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.3, 0.029, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.5, 0.3, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 1.206, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.206, 1.206, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.206, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_4") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5065, 1.1, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.1, 0.5065, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.35, 1.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.1, 0.35, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.8939, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.8939, 0.8939, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.8939, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_6") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 3.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.75, 0.5, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -0.75, 0.5, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.75, -0.5, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -0.75, -0.5, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_12") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 1.0, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.5313, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.4, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.7276, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.7276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_15") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5197, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5313, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.4, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - -0.6259, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.1, -0.3, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.1, -0.3, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.1, 0.4276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_17") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0625, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5197, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.2145, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, -0.4, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.1259, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - return true; - } - - void setDiscontinuityPlacement( const PointType& v ) - { - this->discontinuityPlacement = v; - } - - const PointType& getDiscontinuityPlasement() const - { - return this->discontinuityPlacement; - } - - void setLeftDensity( const RealType& leftDensity ) - { - this->leftDensity = leftDensity; - } - - const RealType& getLeftDensity() const - { - return this->leftDensity; - } - - void setRightDensity( const RealType& rightDensity ) - { - this->rightDensity = rightDensity; - } - - const RealType& getRightDensity() const - { - return this->rightDensity; - } - - void setLeftVelocity( const PointType& leftVelocity ) - { - this->leftVelocity = leftVelocity; - } - - const PointType& getLeftVelocity() const - { - return this->leftVelocity; - } - - void setRightVelocity( const RealType& rightVelocity ) - { - this->rightVelocity = rightVelocity; - } - - const PointType& getRightVelocity() const - { - return this->rightVelocity; - } - - void setLeftPressure( const RealType& leftPressure ) - { - this->leftPressure = leftPressure; - } - - const RealType& getLeftPressure() const - { - return this->leftPressure; - } - - void setRightPressure( const RealType& rightPressure ) - { - this->rightPressure = rightPressure; - } - - const RealType& getRightPressure() const - { - return this->rightPressure; - } - - - void predefinedInitialCondition( double preGamma, double preDiscX, double preDiscY, double preDiscZ, - double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ) - - { - this->discontinuityPlacement = PointLoad(preDiscX, preDiscY, preDiscZ); - this->gamma = preGamma; - - this->NWUDensity = preNWUDensity; - this->NWUVelocity = PointLoad(preNWUVelocityX, preNWUVelocityY, preNWUVelocityZ); - this->NWUPressure = preNWUPressure; - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = preNWUDensity; - this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); - this->SWUPressure = preSWUPressure; - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = preNWDDensity; - this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); - this->NWDPressure = preNWDPressure; - this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = preSWDDensity; - this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); - this->SWDPressure = preSWDPressure; - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = preNEUDensity; - this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); - this->NEUPressure = preNEUPressure; - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = preSEUDensity; - this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); - this->SEUPressure = preSEUPressure; - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = preNEDDensity; - this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); - this->NEDPressure = preNEDPressure; - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = preSEDDensity; - this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); - this->SEDPressure = preSEDPressure; - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - - std::cout << this->SEDEnergy; - std::cout << this->SWDEnergy; - - } - - PointType PointLoad( RealType ValueX, RealType ValueY, RealType ValueZ) - { - PointType point; - switch (Dimensions) - { - case 1: point[ 0 ] = ValueX; - break; - case 2: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - break; - case 3: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - point[ 2 ] = ValueZ; - break; - } - return point; - } - - RealType Energy( RealType Density, RealType Pressure, RealType gamma, PointType Velocity) - { - RealType energy; - switch (Dimensions) - { - case 1: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ))); - break; - case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); - break; - case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 3 ], 2 ))); - break; // druhou mocninu ps8t jako sou4in - } - return energy; - } - - void setInitialCondition( CompressibleConservativeVariables< MeshType >& conservativeVariables, - const PointType& center = PointType( 0.0 ) ) - { - RiemannProblemInitialConditionSetter* variablesSetter = new RiemannProblemInitialConditionSetter; - variablesSetter->setGamma(this->gamma); - variablesSetter->setDensity(this->NWUDensity, - this->NEUDensity, - this->SWUDensity, - this->SEUDensity, - this->NWDDensity, - this->NEDDensity, - this->SWDDensity, - this->SEDDensity); - variablesSetter->setMomentum(this->NWUMomentum, - this->NEUMomentum, - this->SWUMomentum, - this->SEUMomentum, - this->NWDMomentum, - this->NEDMomentum, - this->SWDMomentum, - this->SEDMomentum); - variablesSetter->setEnergy(this->NWUEnergy, - this->NEUEnergy, - this->SWUEnergy, - this->SEUEnergy, - this->NWDEnergy, - this->NEDEnergy, - this->SWDEnergy, - this->SEDEnergy); - variablesSetter->setDiscontinuity(this->discontinuityPlacement); - variablesSetter->placeDensity(conservativeVariables); - variablesSetter->placeMomentum(conservativeVariables); - variablesSetter->placeEnergy(conservativeVariables); - -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - -/* - typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; - typedef Operators::Analytic::Sign< Dimensions, RealType > SignType; - typedef Functions::OperatorFunction< SignType, VectorNormType > InitialConditionType; - typedef Pointers::SharedPointer< InitialConditionType, DeviceType > InitialConditionPointer; - - InitialConditionPointer initialCondition; - initialCondition->getFunction().setCenter( center ); - initialCondition->getFunction().setMaxNorm( true ); - initialCondition->getFunction().setRadius( discontinuityPlacement[ 0 ] ); - discontinuityPlacement *= 1.0 / discontinuityPlacement[ 0 ]; - for( int i = 1; i < Dimensions; i++ ) - discontinuityPlacement[ i ] = 1.0 / discontinuityPlacement[ i ]; - initialCondition->getFunction().setAnisotropy( discontinuityPlacement ); - initialCondition->getFunction().setMultiplicator( -1.0 ); - - Functions::MeshFunctionEvaluator< MeshFunctionType, InitialConditionType > evaluator; -*/ - /**** - * Density - */ -/* - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ -/* - initialCondition->getOperator().setPositiveValue( leftDensity ); - initialCondition->getOperator().setNegativeValue( rightDensity ); - evaluator.evaluate( conservativeVariables.getDensity(), initialCondition ); - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ - /**** - * Momentum - */ - -/* - for( int i = 0; i < Dimensions; i++ ) - { - initialCondition->getOperator().setPositiveValue( leftDensity * leftVelocity[ i ] ); - initialCondition->getOperator().setNegativeValue( rightDensity * rightVelocity[ i ] ); - evaluator.evaluate( conservativeVariables.getMomentum()[ i ], initialCondition ); - } -*/ - /**** - * Energy - */ -/* - conservativeVariables.getEnergy()->write( "energy-init", "gnuplot" ); -*/ -/* - const RealType leftKineticEnergy = leftVelocity.lpNorm( 2.0 ); - const RealType rightKineticEnergy = rightVelocity.lpNorm( 2.0 ); - const RealType leftEnergy = leftPressure / ( gamma - 1.0 ) + 0.5 * leftDensity * leftKineticEnergy * leftKineticEnergy; - const RealType rightEnergy = rightPressure / ( gamma - 1.0 ) + 0.5 * rightDensity * rightKineticEnergy * rightKineticEnergy; - initialCondition->getOperator().setPositiveValue( leftEnergy ); - initialCondition->getOperator().setNegativeValue( rightEnergy ); - evaluator.evaluate( (* conservativeVariables.getEnergy()), initialCondition ); - (* conservativeVariables.getEnergy())->write( "energy-init", "gnuplot" ); -*/ - } - - - protected: - - PointType discontinuityPlacement; - PointType NWUVelocity, NEUVelocity, SWUVelocity, SEUVelocity, NWDVelocity, NEDVelocity, SWDVelocity, SEDVelocity; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUPressure, NEUPressure, SWUPressure, SEUPressure, NWDPressure, NEDPressure, SWDPressure, SEDPressure; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType leftDensity, rightDensity; - PointType leftVelocity, rightVelocity; - RealType leftPressure, rightPressure; - - RealType gamma; // gamma in the ideal gas state equation -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow/euler.cpp b/src/Examples/inviscid-flow/euler.cpp deleted file mode 100644 index 4d76005cb..000000000 --- a/src/Examples/inviscid-flow/euler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "euler.h" diff --git a/src/Examples/inviscid-flow/euler.cu b/src/Examples/inviscid-flow/euler.cu deleted file mode 100644 index 4d76005cb..000000000 --- a/src/Examples/inviscid-flow/euler.cu +++ /dev/null @@ -1 +0,0 @@ -#include "euler.h" diff --git a/src/Examples/inviscid-flow/euler.h b/src/Examples/inviscid-flow/euler.h deleted file mode 100644 index 0bd0c6664..000000000 --- a/src/Examples/inviscid-flow/euler.h +++ /dev/null @@ -1,120 +0,0 @@ -#include -#include -#include -#include -#include -#include "eulerProblem.h" -#include "LaxFridrichs.h" -#include "eulerRhs.h" -#include "eulerBuildConfigTag.h" - -#include "RiemannProblemInitialCondition.h" - -using namespace TNL; - -typedef eulerBuildConfigTag BuildConfig; - -/**** - * Uncomment the following (and comment the previous line) for the complete build. - * This will include support for all floating point precisions, all indexing types - * and more solvers. You may then choose between them from the command line. - * The compile time may, however, take tens of minutes or even several hours, - * especially if CUDA is enabled. Use this, if you want, only for the final build, - * not in the development phase. - */ -//typedef tnlDefaultConfigTag BuildConfig; - -template< typename ConfigTag >class eulerConfig -{ - public: - static void configSetup( Config::ConfigDescription & config ) - { - config.addDelimiter( "Inviscid flow settings:" ); - config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "dirichlet"); - config.addEntryEnum< String >( "dirichlet" ); - config.addEntryEnum< String >( "neumann" ); - config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); - typedef Meshes::Grid< 3 > Mesh; - LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); - RiemannProblemInitialCondition< Mesh >::configSetup( config ); - - /**** - * Add definition of your solver command line arguments. - */ - - } -}; - -template< typename Real, - typename Device, - typename Index, - typename MeshType, - typename ConfigTag, - typename SolverStarter, - typename CommunicatorType > -class eulerSetter -{ - public: - - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - static bool run( const Config::ParameterContainer & parameters ) - { - enum { Dimension = MeshType::getMeshDimension() }; - typedef LaxFridrichs< MeshType, Real, Index > ApproximateOperator; - typedef eulerRhs< MeshType, Real > RightHandSide; - typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; - - /**** - * Resolve the template arguments of your solver here. - * The following code is for the Dirichlet and the Neumann boundary conditions. - * Both can be constant or defined as descrete values of Vector. - */ - String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); - if( parameters.checkParameter( "boundary-conditions-constant" ) ) - { - typedef Functions::Analytic::Constant< Dimension, Real > Constant; - if( boundaryConditionsType == "dirichlet" ) - { - typedef Operators::DirichletBoundaryConditions< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "neumann" ) - { - typedef Operators::NeumannBoundaryConditions< MeshType, Constant, Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - } - typedef Functions::MeshFunction< MeshType > MeshFunction; - if( boundaryConditionsType == "dirichlet" ) - { - typedef Operators::DirichletBoundaryConditions< MeshType, MeshFunction, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "neumann" ) - { - typedef Operators::NeumannBoundaryConditions< MeshType, MeshFunction, Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - - return true;} - -}; - -int main( int argc, char* argv[] ) -{ - Solvers::Solver< eulerSetter, eulerConfig, BuildConfig > solver; - if( ! solver. run( argc, argv ) ) - return EXIT_FAILURE; - return EXIT_SUCCESS; -} diff --git a/src/Examples/inviscid-flow/eulerBuildConfigTag.h b/src/Examples/inviscid-flow/eulerBuildConfigTag.h deleted file mode 100644 index 872b4e17a..000000000 --- a/src/Examples/inviscid-flow/eulerBuildConfigTag.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef eulerBUILDCONFIGTAG_H_ -#define eulerBUILDCONFIGTAG_H_ - -#include -#include - -namespace TNL { - -class eulerBuildConfigTag{}; - -namespace Solvers { - -/**** - * Turn off support for float and long double. - */ -template<> struct ConfigTagReal< eulerBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct ConfigTagReal< eulerBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct ConfigTagIndex< eulerBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct ConfigTagIndex< eulerBuildConfigTag, long int >{ enum { enabled = false }; }; - -//template< int Dimension > struct ConfigTagDimension< eulerBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; - -/**** - * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. - */ -/*template< int Dimension, typename Real, typename Device, typename Index > - struct ConfigTagMesh< eulerBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > - { enum { enabled = ConfigTagDimension< eulerBuildConfigTag, Dimension >::enabled && - ConfigTagReal< eulerBuildConfigTag, Real >::enabled && - ConfigTagDevice< eulerBuildConfigTag, Device >::enabled && - ConfigTagIndex< eulerBuildConfigTag, Index >::enabled }; }; -*/ -/**** - * Please, chose your preferred time discretisation here. - */ -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; -template<> struct ConfigTagTimeDiscretisation< eulerBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; - -/**** - * Only the Runge-Kutta-Merson solver is enabled by default. - */ -template<> struct ConfigTagExplicitSolver< eulerBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; - -} // namespace Solvers - -namespace Meshes { -namespace BuildConfigTags { - -template< int Dimensions > struct GridDimensionTag< eulerBuildConfigTag, Dimensions >{ enum { enabled = ( Dimensions == 1 ) }; }; - -/**** - * Turn off support for float and long double. - */ -template<> struct GridRealTag< eulerBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct GridRealTag< eulerBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct GridIndexTag< eulerBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct GridIndexTag< eulerBuildConfigTag, long int >{ enum { enabled = false }; }; - -} // namespace BuildConfigTags -} // namespace Meshes -} // namespace TNL - -#endif /* eulerBUILDCONFIGTAG_H_ */ diff --git a/src/Examples/inviscid-flow/eulerProblem.h b/src/Examples/inviscid-flow/eulerProblem.h deleted file mode 100644 index a854f8098..000000000 --- a/src/Examples/inviscid-flow/eulerProblem.h +++ /dev/null @@ -1,121 +0,0 @@ -/*************************************************************************** - eulerProblem.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include "CompressibleConservativeVariables.h" - - -using namespace TNL::Problems; - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -class eulerProblem: - public PDEProblem< Mesh, - Communicator, - typename InviscidOperators::RealType, - typename Mesh::DeviceType, - typename InviscidOperators::IndexType > -{ - public: - - typedef typename InviscidOperators::RealType RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef typename InviscidOperators::IndexType IndexType; - typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; - - typedef Communicator CommunicatorType; - - using typename BaseType::MeshType; - using typename BaseType::MeshPointer; - using typename BaseType::DofVectorType; - using typename BaseType::DofVectorPointer; - static const int Dimensions = Mesh::getMeshDimension(); - - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; - typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; - typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; - - static String getType(); - - String getPrologHeader() const; - - void writeProlog( Logger& logger, - const Config::ParameterContainer& parameters ) const; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ); - - bool setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ); - - template< typename Matrix > - bool setupLinearSystem( Matrix& matrix ); - - bool makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ); - - IndexType getDofs() const; - - void bindDofs( DofVectorPointer& dofs ); - - void getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ); - - void applyBoundaryConditions( const RealType& time, - DofVectorPointer& dofs ); - - template< typename Matrix > - void assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs, - Matrix& matrix, - DofVectorPointer& rightHandSide ); - - bool postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ); - - protected: - - InviscidOperatorsPointer inviscidOperatorsPointer; - - BoundaryConditionPointer boundaryConditionPointer; - RightHandSidePointer rightHandSidePointer; - - ConservativeVariablesPointer conservativeVariables, - conservativeVariablesRHS; - - VelocityFieldPointer velocity; - MeshFunctionPointer pressure; - - RealType gamma; -}; - -} // namespace TNL - -#include "eulerProblem_impl.h" - diff --git a/src/Examples/inviscid-flow/eulerProblem_impl.h b/src/Examples/inviscid-flow/eulerProblem_impl.h deleted file mode 100644 index fd64ae284..000000000 --- a/src/Examples/inviscid-flow/eulerProblem_impl.h +++ /dev/null @@ -1,425 +0,0 @@ -/*************************************************************************** - eulerProblem_impl.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include - -#include "RiemannProblemInitialCondition.h" -#include "CompressibleConservativeVariables.h" -#include "PhysicalVariablesGetter.h" -#include "eulerProblem.h" - -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getType() -{ - return String( "eulerProblem< " ) + Mesh :: getType() + " >"; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getPrologHeader() const -{ - return String( "Inviscid flow solver" ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const -{ - /**** - * Add data you want to have in the computation report (log) as follows: - * logger.writeParameter< double >( "Parameter description", parameter ); - */ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -setup( const Config::ParameterContainer& parameters, - const String& prefix ) -{ - if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || - ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || - ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) - return false; - this->gamma = parameters.getParameter< double >( "gamma" ); - velocity->setMesh( this->getMesh() ); - pressure->setMesh( this->getMesh() ); - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -typename eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >::IndexType -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getDofs() const -{ - /**** - * Return number of DOFs (degrees of freedom) i.e. number - * of unknowns to be resolved by the main solver. - */ - return this->conservativeVariables->getDofs( this->getMesh() ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -bindDofs( DofVectorPointer& dofVector ) -{ - this->conservativeVariables->bind( this->getMesh(), dofVector ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ) -{ - CompressibleConservativeVariables< MeshType > conservativeVariables; - conservativeVariables.bind( this->getMesh(), dofs ); - const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); - if( initialConditionType == "riemann-problem" ) - { - RiemannProblemInitialCondition< MeshType > initialCondition; - if( ! initialCondition.setup( parameters ) ) - return false; - initialCondition.setInitialCondition( conservativeVariables ); - return true; - } - std::cerr << "Unknown initial condition " << initialConditionType << std::endl; - return false; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > - template< typename Matrix > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -setupLinearSystem( Matrix& matrix ) -{ -/* const IndexType dofs = this->getDofs(); - typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; - CompressedRowLengthsVectorType rowLengths; - if( ! rowLengths.setSize( dofs ) ) - return false; - MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; - matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, - differentialOperator, - boundaryCondition, - rowLengths ); - matrix.setDimensions( dofs, dofs ); - if( ! matrix.setCompressedRowLengths( rowLengths ) ) - return false;*/ - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ) -{ - std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; - - this->bindDofs( dofs ); - PhysicalVariablesGetter< MeshType > physicalVariablesGetter; - physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - FileName fileName; - fileName.setExtension( "tnl" ); - fileName.setIndex( step ); - fileName.setFileNameBase( "density-" ); - this->conservativeVariables->getDensity()->save( fileName.getFileName() ); - - fileName.setFileNameBase( "velocity-" ); - this->velocity->save( fileName.getFileName() ); - - fileName.setFileNameBase( "pressure-" ); - this->pressure->save( fileName.getFileName() ); - - fileName.setFileNameBase( "energy-" ); - this->conservativeVariables->getEnergy()->save( fileName.getFileName() ); - - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ) -{ - typedef typename MeshType::Cell Cell; - - /**** - * Bind DOFs - */ - this->conservativeVariables->bind( this->getMesh(), _u ); - this->conservativeVariablesRHS->bind( this->getMesh(), _fu ); - this->velocity->setMesh( this->getMesh() ); - this->pressure->setMesh( this->getMesh() ); - - /**** - * Resolve the physical variables - */ - PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; - physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - /**** - * Set-up operators - */ - typedef typename InviscidOperators::ContinuityOperatorType ContinuityOperatorType; - typedef typename InviscidOperators::MomentumXOperatorType MomentumXOperatorType; - typedef typename InviscidOperators::MomentumYOperatorType MomentumYOperatorType; - typedef typename InviscidOperators::MomentumZOperatorType MomentumZOperatorType; - typedef typename InviscidOperators::EnergyOperatorType EnergyOperatorType; - - this->inviscidOperatorsPointer->setTau( tau ); - this->inviscidOperatorsPointer->setVelocity( this->velocity ); - this->inviscidOperatorsPointer->setPressure( this->pressure ); - - /**** - * Continuity equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, ContinuityOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterContinuity; - explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); - explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - this->conservativeVariables->getDensity(), - this->conservativeVariablesRHS->getDensity() ); - - /**** - * Momentum equations - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumXOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumX; - explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); - explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); - - if( Dimensions > 1 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumYOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumY; - explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); - explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); - } - - if( Dimensions > 2 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumZ; - explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); - explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); - } - - - /**** - * Energy equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, EnergyOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterEnergy; - explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); - explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - this->conservativeVariables->getEnergy(), // uRhoVelocityX, - this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); - - /*this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); - this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); - this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); - getchar();*/ - -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -applyBoundaryConditions( const RealType& time, - DofVectorPointer& dofs ) -{ - this->bindDofs( dofs ); - throw Exceptions::NotImplementedError( "TODO: implement BC ... see HeatEquationProblem" ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > - template< typename Matrix > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - Matrix& matrix, - DofVectorPointer& b ) -{ -/* LinearSystemAssembler< Mesh, - MeshFunctionType, - InviscidOperators, - BoundaryCondition, - RightHandSide, - BackwardTimeDiscretisation, - Matrix, - DofVectorType > systemAssembler; - - MeshFunction< Mesh > u( mesh, _u ); - systemAssembler.template assembly< typename Mesh::Cell >( time, - tau, - this->differentialOperator, - this->boundaryCondition, - this->rightHandSide, - u, - matrix, - b );*/ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ) -{ - /* - typedef typename MeshType::Cell Cell; - int count = mesh->template getEntitiesCount< Cell >()/4; - //bind _u - this->_uRho.bind( *dofs, 0, count); - this->_uRhoVelocityX.bind( *dofs, count, count); - this->_uRhoVelocityY.bind( *dofs, 2 * count, count); - this->_uEnergy.bind( *dofs, 3 * count, count); - - MeshFunctionType velocity( mesh, this->velocity ); - MeshFunctionType velocityX( mesh, this->velocityX ); - MeshFunctionType velocityY( mesh, this->velocityY ); - MeshFunctionType pressure( mesh, this->pressure ); - MeshFunctionType uRho( mesh, _uRho ); - MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); - MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); - MeshFunctionType uEnergy( mesh, _uEnergy ); - //Generating differential operators - Velocity euler2DVelocity; - VelocityX euler2DVelocityX; - VelocityY euler2DVelocityY; - Pressure euler2DPressure; - - //velocityX - euler2DVelocityX.setRhoVelX(uRhoVelocityX); - euler2DVelocityX.setRho(uRho); -// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; -// velocityX = OFVelocityX; - - //velocityY - euler2DVelocityY.setRhoVelY(uRhoVelocityY); - euler2DVelocityY.setRho(uRho); -// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; -// velocityY = OFVelocityY; - - //velocity - euler2DVelocity.setVelX(velocityX); - euler2DVelocity.setVelY(velocityY); -// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; -// velocity = OFVelocity; - - //pressure - euler2DPressure.setGamma(gamma); - euler2DPressure.setVelocity(velocity); - euler2DPressure.setEnergy(uEnergy); - euler2DPressure.setRho(uRho); -// OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure; -// pressure = OFPressure; - */ - return true; -} - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow/eulerRhs.h b/src/Examples/inviscid-flow/eulerRhs.h deleted file mode 100644 index 51d4e0243..000000000 --- a/src/Examples/inviscid-flow/eulerRhs.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef eulerRHS_H_ -#define eulerRHS_H_ - -#include - -namespace TNL { - -template< typename Mesh, typename Real >class eulerRhs - : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > - { - public: - - typedef Mesh MeshType; - typedef Real RealType; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; - } - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const Real& time = 0.0 ) const - { - typedef typename MeshEntity::MeshType::PointType PointType; - PointType v = entity.getCenter(); - return 0.0; - } -}; - -} //namespace TNL - -#endif /* eulerRHS_H_ */ -- GitLab From b3690acc9fc1fe0932b0c5ad4c7f1cdfffbda939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Wed, 17 Oct 2018 19:34:02 +0200 Subject: [PATCH 03/28] resolved work for host /cuda in differential operators --- .../Lax-Friedrichs/LaxFridrichsContinuity.h | 61 ++--- .../Euler/Lax-Friedrichs/LaxFridrichsEnergy.h | 73 +++--- .../Lax-Friedrichs/LaxFridrichsMomentumX.h | 68 +++--- .../Lax-Friedrichs/LaxFridrichsMomentumY.h | 60 ++--- .../Lax-Friedrichs/LaxFridrichsMomentumZ.h | 35 +-- .../Steger-Warming/StegerWarmingContinuity.h | 42 ++-- .../Steger-Warming/StegerWarmingEnergy.h | 88 +++---- .../Steger-Warming/StegerWarmingMomentumX.h | 69 +++--- .../Steger-Warming/StegerWarmingMomentumY.h | 48 ++-- .../Steger-Warming/StegerWarmingMomentumZ.h | 32 +-- .../Euler/VanLeer/VanLeerContinuity.h | 42 ++-- .../Euler/VanLeer/VanLeerEnergy.h | 86 +++---- .../Euler/VanLeer/VanLeerMomentumX.h | 75 +++--- .../Euler/VanLeer/VanLeerMomentumY.h | 52 ++--- .../Euler/VanLeer/VanLeerMomentumZ.h | 32 +-- .../Lax-Friedrichs/LaxFridrichs.h | 3 +- .../Lax-Friedrichs/LaxFridrichsContinuity.h | 97 +++++--- .../Lax-Friedrichs/LaxFridrichsEnergy.h | 217 +++++++++--------- .../Lax-Friedrichs/LaxFridrichsMomentumX.h | 183 +++++++-------- .../Lax-Friedrichs/LaxFridrichsMomentumY.h | 179 ++++++++------- .../Lax-Friedrichs/LaxFridrichsMomentumZ.h | 109 ++++----- .../Steger-Warming/StegerWarmingContinuity.h | 36 +-- .../Steger-Warming/StegerWarmingEnergy.h | 213 ++++++++--------- .../Steger-Warming/StegerWarmingMomentumX.h | 197 ++++++++-------- .../Steger-Warming/StegerWarmingMomentumY.h | 182 +++++++-------- .../Steger-Warming/StegerWarmingMomentumZ.h | 117 +++++----- .../Navier-Stokes/VanLeer/VanLeerContinuity.h | 38 +-- .../Navier-Stokes/VanLeer/VanLeerEnergy.h | 213 ++++++++--------- .../Navier-Stokes/VanLeer/VanLeerMomentumX.h | 199 ++++++++-------- .../Navier-Stokes/VanLeer/VanLeerMomentumY.h | 182 +++++++-------- .../Navier-Stokes/VanLeer/VanLeerMomentumZ.h | 117 +++++----- src/Examples/flows/navierStokes.h | 4 +- 32 files changed, 1632 insertions(+), 1517 deletions(-) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h index 45ad4d52b..2c1404746 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h @@ -114,11 +114,14 @@ class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Re const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; } @@ -173,17 +176,20 @@ class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse @@ -243,20 +249,23 @@ class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Re const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h index 18c824762..a3676e506 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -116,13 +116,17 @@ class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse; @@ -180,21 +184,25 @@ class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) @@ -253,16 +261,17 @@ class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; @@ -271,12 +280,14 @@ class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h index 63def12d3..35e75cff1 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h @@ -67,13 +67,16 @@ class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Rea const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) @@ -139,20 +142,23 @@ class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) @@ -219,16 +225,17 @@ class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; @@ -237,12 +244,15 @@ class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real //const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; //const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h index 8ce42282d..9c6308385 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h @@ -128,20 +128,23 @@ class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) @@ -208,25 +211,30 @@ class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h index a67e862ce..d67532b56 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h @@ -188,25 +188,30 @@ class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h index 105a6e432..0bc097d1f 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h @@ -150,16 +150,16 @@ class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, R const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) @@ -219,8 +219,8 @@ class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, R const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); @@ -234,13 +234,13 @@ class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, R const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) @@ -326,17 +326,17 @@ class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, R const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h index 912b0156c..72de3016d 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h @@ -180,8 +180,8 @@ class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -191,9 +191,9 @@ class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) @@ -302,8 +302,8 @@ class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); @@ -323,17 +323,17 @@ class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) @@ -447,9 +447,9 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); @@ -475,29 +475,29 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h index 36f71ce84..62b999e79 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h @@ -67,21 +67,22 @@ class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Re const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) @@ -150,8 +151,8 @@ class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); @@ -171,15 +172,15 @@ class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) @@ -283,21 +284,21 @@ class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h index 4c03ba324..342a6f0ea 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h @@ -149,15 +149,15 @@ class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) @@ -231,9 +231,9 @@ class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); @@ -259,21 +259,21 @@ class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h index 9fe6b4123..95064b241 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h @@ -188,9 +188,9 @@ class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); @@ -216,21 +216,21 @@ class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h index 2c8217465..94a40dcbf 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h @@ -151,16 +151,16 @@ class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, I const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) @@ -220,8 +220,8 @@ class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, I const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); @@ -235,13 +235,13 @@ class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, I const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) @@ -327,17 +327,17 @@ class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, I const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h index 2f0daead3..ac933fcb1 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h @@ -166,7 +166,7 @@ class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; @@ -177,9 +177,9 @@ class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) @@ -276,8 +276,8 @@ class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); @@ -297,17 +297,17 @@ class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) @@ -411,9 +411,9 @@ class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); @@ -439,29 +439,29 @@ class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h index 948e8349b..28ae3e808 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h @@ -67,21 +67,22 @@ class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, In const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) @@ -150,8 +151,8 @@ class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); @@ -171,15 +172,15 @@ class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) @@ -255,9 +256,9 @@ class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); @@ -283,21 +284,21 @@ class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h index c8483e075..8fb8f7aff 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h @@ -128,8 +128,8 @@ class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); @@ -149,15 +149,15 @@ class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) @@ -231,9 +231,9 @@ class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); @@ -259,21 +259,21 @@ class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h index 6ea3da270..600b566e7 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h @@ -188,9 +188,9 @@ class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); @@ -216,21 +216,21 @@ class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h index 1e119661c..aa370506b 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h @@ -24,6 +24,7 @@ namespace TNL { template< typename Mesh, + int OperatorRightHandSide = 0, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class LaxFridrichs @@ -37,7 +38,7 @@ class LaxFridrichs static const int Dimensions = Mesh::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - typedef LaxFridrichsContinuity< Mesh, Real, Index > ContinuityOperatorType; + typedef LaxFridrichsContinuity< Mesh, OperatorRightHandSide, Real, Index > ContinuityOperatorType; typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h index d821224f1..21d20479b 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h @@ -74,6 +74,7 @@ class LaxFridrichsContinuityBase template< typename Mesh, + int OperatorRightHandSide = 0, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class LaxFridrichsContinuity @@ -85,9 +86,10 @@ class LaxFridrichsContinuity template< typename MeshReal, typename Device, typename MeshIndex, + int OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > { public: @@ -103,6 +105,12 @@ class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Re using typename BaseType::VelocityFieldPointer; using BaseType::Dimensions; +/* template < int OperatorRHS > + __cuda_callable__ + Real rightHandSide() + { + }*/ + template< typename MeshFunction, typename MeshEntity > __cuda_callable__ Real operator()( const MeshFunction& u, @@ -114,15 +122,19 @@ class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Re const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + // return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) // - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; + //+ rightHandSide(); } /*template< typename MeshEntity > @@ -142,13 +154,38 @@ class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Re Vector& b, MatrixRow& matrixRow ) const;*/ }; +/* +template< typename MeshReal, + typename Device, + typename MeshIndex, + int OperatorRightHandSide, + typename Real, + typename Index > + template<> //Euler +__cuda_callable__ +Real +LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index >:: +rightHandSide<1>() + { + return 0; + } +/* + template<> //Navier-Stokes + __cuda_callable__ + RealType rightHandSide<1>() + { + return 0; + } +*/ + template< typename MeshReal, typename Device, typename MeshIndex, + int OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > { public: @@ -177,15 +214,17 @@ class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re //rho const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse @@ -213,9 +252,10 @@ class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re template< typename MeshReal, typename Device, typename MeshIndex, + int OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > { public: @@ -244,21 +284,22 @@ class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Re //rho const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h index e7cdd91be..950898fab 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -120,19 +120,20 @@ class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east @@ -195,45 +196,46 @@ class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) @@ -324,32 +326,33 @@ class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; @@ -358,53 +361,53 @@ class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h index 3e295c029..f2afe8d4b 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h @@ -67,18 +67,19 @@ class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Rea const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) @@ -148,41 +149,42 @@ class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) @@ -261,32 +263,33 @@ class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; @@ -295,40 +298,40 @@ class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h index 0df12c522..b61415cd2 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h @@ -128,40 +128,42 @@ class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) @@ -240,32 +242,33 @@ class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; @@ -274,41 +277,41 @@ class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h index e4f8501ec..51f51734e 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h @@ -188,32 +188,33 @@ class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; @@ -222,41 +223,41 @@ class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h index 4cbee5c09..004def45f 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h @@ -162,9 +162,9 @@ class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, R const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) @@ -239,13 +239,13 @@ class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, R const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) @@ -331,17 +331,17 @@ class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, R const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h index 9f289fb2b..824573476 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h @@ -183,11 +183,12 @@ class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -197,9 +198,9 @@ class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) @@ -313,20 +314,21 @@ class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -340,25 +342,25 @@ class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) @@ -504,32 +506,33 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -547,53 +550,53 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h index a8440605c..d3d8e5695 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h @@ -67,23 +67,24 @@ class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Re const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) @@ -157,19 +158,20 @@ class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -183,23 +185,23 @@ class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) @@ -287,32 +289,33 @@ class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -330,45 +333,45 @@ class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h index 943663782..c3daa16e9 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h @@ -128,20 +128,21 @@ class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -155,23 +156,23 @@ class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) @@ -257,32 +258,33 @@ class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -300,45 +302,45 @@ class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h index b74e36c2b..8c9f29a28 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h @@ -188,32 +188,33 @@ class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -231,45 +232,45 @@ class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h index 2c8217465..c105b8a83 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h @@ -151,16 +151,16 @@ class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, I const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) @@ -235,13 +235,13 @@ class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, I const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) @@ -327,17 +327,17 @@ class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, I const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h index ed1166c3f..698d1625d 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h @@ -169,11 +169,12 @@ class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -183,9 +184,9 @@ class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) @@ -287,20 +288,21 @@ class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -314,25 +316,25 @@ class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) @@ -468,32 +470,33 @@ class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -511,53 +514,53 @@ class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h index d6122d37e..8b7673a09 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h @@ -67,23 +67,24 @@ class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, In const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) @@ -156,20 +157,21 @@ class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -183,23 +185,23 @@ class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) @@ -287,32 +289,33 @@ class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -330,45 +333,45 @@ class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h index 2a5e4a23a..225903dd2 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h @@ -128,20 +128,21 @@ class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -155,23 +156,23 @@ class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) @@ -257,32 +258,33 @@ class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -300,45 +302,45 @@ class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h index 5b2ec810b..3567f5815 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h @@ -188,32 +188,33 @@ class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -231,45 +232,45 @@ class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/navierStokes.h b/src/Examples/flows/navierStokes.h index e8ec526d2..e9deffed6 100644 --- a/src/Examples/flows/navierStokes.h +++ b/src/Examples/flows/navierStokes.h @@ -75,12 +75,12 @@ class navierStokesSetter static bool run( const Config::ParameterContainer & parameters ) { enum { Dimension = MeshType::getMeshDimension() }; - typedef LaxFridrichs< MeshType, Real, Index > ApproximateOperator; + typedef LaxFridrichs< MeshType, 0, Real, Index > ApproximateOperator; typedef flowsRhs< MeshType, Real > RightHandSide; typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); if( differentialOperatorType == "Lax-Friedrichs" ) - typedef LaxFridrichs< MeshType, Real, Index > ApproximateOperator; + typedef LaxFridrichs< MeshType, 0, Real, Index > ApproximateOperator; else if( differentialOperatorType == "Steger-Warming" ) typedef StegerWarming< MeshType, Real, Index > ApproximateOperator; else if( differentialOperatorType == "VanLeer" ) -- GitLab From 56108685b28dba10e139b6d0c882a3a348c931a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Thu, 25 Oct 2018 09:21:27 +0200 Subject: [PATCH 04/28] finished merge, L-F and S-W operators changed to accept classes as equation's RHS --- .../Boiler/BoundaryConditionsBoiler.h | 16 +- .../CompressibleConservativeVariables.h | 10 +- .../Boiler/DensityBoundaryConditionBoiler.h | 12 +- .../Boiler/EnergyBoundaryConditionBoiler.h | 13 +- .../Boiler/MomentumXBoundaryConditionBoiler.h | 12 +- .../Boiler/MomentumYBoundaryConditionBoiler.h | 12 +- .../Boiler/MomentumZBoundaryConditionBoiler.h | 12 +- .../Cavity/BoundaryConditionsCavity.h | 16 +- .../CompressibleConservativeVariables.h | 10 +- .../Cavity/DensityBoundaryConditionCavity.h | 12 +- .../Cavity/EnergyBoundaryConditionCavity.h | 13 +- .../Cavity/MomentumXBoundaryConditionCavity.h | 12 +- .../Cavity/MomentumYBoundaryConditionCavity.h | 12 +- .../Cavity/MomentumZBoundaryConditionCavity.h | 12 +- src/Examples/flows/CMakeLists.txt | 52 +- .../flows/CompressibleConservativeVariables.h | 10 +- .../Euler/Lax-Friedrichs/LaxFridrichs.h | 16 +- .../Lax-Friedrichs/LaxFridrichsContinuity.h | 4 +- .../Euler/Lax-Friedrichs/LaxFridrichsEnergy.h | 4 +- .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 4 +- .../Euler/Steger-Warming/StegerWarming.h | 16 +- .../Steger-Warming/StegerWarmingContinuity.h | 6 +- .../Steger-Warming/StegerWarmingEnergy.h | 4 +- .../StegerWarmingMomentumBase.h | 4 +- .../Euler/VanLeer/VanLeer.h | 16 +- .../Euler/VanLeer/VanLeerContinuity.h | 6 +- .../Euler/VanLeer/VanLeerEnergy.h | 4 +- .../Euler/VanLeer/VanLeerMomentumBase.h | 4 +- .../Lax-Friedrichs/LaxFridrichs.h | 38 +- .../Lax-Friedrichs/LaxFridrichsContinuity.h | 71 +-- .../Lax-Friedrichs/LaxFridrichsEnergy.h | 156 +----- .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 10 +- .../Lax-Friedrichs/LaxFridrichsMomentumX.h | 64 +-- .../Lax-Friedrichs/LaxFridrichsMomentumY.h | 58 +-- .../Lax-Friedrichs/LaxFridrichsMomentumZ.h | 47 +- .../Steger-Warming/StegerWarming.h | 37 +- .../Steger-Warming/StegerWarmingContinuity.h | 44 +- .../Steger-Warming/StegerWarmingEnergy.h | 156 +----- .../StegerWarmingMomentumBase.h | 10 +- .../Steger-Warming/StegerWarmingMomentumX.h | 64 +-- .../Steger-Warming/StegerWarmingMomentumY.h | 58 +-- .../Steger-Warming/StegerWarmingMomentumZ.h | 47 +- .../Navier-Stokes/VanLeer/VanLeer.h | 16 +- .../Navier-Stokes/VanLeer/VanLeerContinuity.h | 6 +- .../Navier-Stokes/VanLeer/VanLeerEnergy.h | 4 +- .../VanLeer/VanLeerMomentumBase.h | 4 +- ...ierStokesContinuityOperatorRightHandSide.h | 218 ++++++++ .../NavierStokesEnergyOperatorRightHandSide.h | 474 ++++++++++++++++++ ...rStokesMomentumBaseOperatorRightHandSide.h | 54 ++ ...vierStokesMomentumXOperatorRightHandSide.h | 358 +++++++++++++ ...vierStokesMomentumYOperatorRightHandSide.h | 345 +++++++++++++ ...vierStokesMomentumZOperatorRightHandSide.h | 301 +++++++++++ .../NavierStokesOperatorRightHandSide.h | 122 +++++ .../nullContinuityOperatorRightHandSide.h | 218 ++++++++ .../nullEnergyOperatorRightHandSide.h | 229 +++++++++ .../nullMomentumBaseOperatorRightHandSide.h | 54 ++ .../nullMomentumXOperatorRightHandSide.h | 211 ++++++++ .../nullMomentumYOperatorRightHandSide.h | 213 ++++++++ .../nullMomentumZOperatorRightHandSide.h | 212 ++++++++ .../nullOperatorRightHandSide.h | 122 +++++ src/Examples/flows/PhysicalVariablesGetter.h | 12 +- .../flows/RiemannProblemInitialCondition.h | 8 +- src/Examples/flows/eulerProblem.h | 13 +- src/Examples/flows/navierStokes.h | 17 +- src/Examples/flows/navierStokesProblem.h | 12 +- 65 files changed, 3616 insertions(+), 791 deletions(-) create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesContinuityOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumBaseOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumXOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumYOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumZOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullContinuityOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullEnergyOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumBaseOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumXOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumYOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumZOperatorRightHandSide.h create mode 100644 src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h diff --git a/src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h index 0cba68d7f..f61f988da 100644 --- a/src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h +++ b/src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h @@ -29,14 +29,14 @@ class BoundaryConditionsBoiler typedef TNL::Operators::EnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; - typedef SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; - typedef SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; - typedef SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; - typedef SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshType > MeshPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) diff --git a/src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h b/src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h index a3afc8453..01e820686 100644 --- a/src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h +++ b/src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h @@ -13,7 +13,7 @@ #include #include -#include +#include namespace TNL { @@ -28,9 +28,9 @@ class CompressibleConservativeVariables typedef typename MeshType::IndexType IndexType; typedef Functions::MeshFunction< Mesh > MeshFunctionType; typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshType > MeshPointer; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > MomentumFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; CompressibleConservativeVariables(){}; @@ -144,4 +144,4 @@ class CompressibleConservativeVariables }; -} // namespace TN \ No newline at end of file +} // namespace TN diff --git a/src/Examples/flows/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h index c3bae7e3d..6231f6780 100644 --- a/src/Examples/flows/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h +++ b/src/Examples/flows/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h @@ -114,8 +114,8 @@ class DensityBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIn typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -237,8 +237,8 @@ class DensityBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIn typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -387,8 +387,8 @@ class DensityBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIn typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > diff --git a/src/Examples/flows/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h index fe227d68f..412640b54 100644 --- a/src/Examples/flows/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h +++ b/src/Examples/flows/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h @@ -12,7 +12,6 @@ #pragma once #include -#include "CompressibleConservativeVariables.h" namespace TNL { namespace Operators { @@ -116,8 +115,8 @@ class EnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshInd typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > @@ -255,8 +254,8 @@ class EnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshInd typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -535,8 +534,8 @@ class EnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshInd typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > diff --git a/src/Examples/flows/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h index 823ec475a..dfe63e076 100644 --- a/src/Examples/flows/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h +++ b/src/Examples/flows/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h @@ -114,8 +114,8 @@ class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, Mesh typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > @@ -245,8 +245,8 @@ class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, Mesh typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -421,8 +421,8 @@ class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, Mesh typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > diff --git a/src/Examples/flows/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h index 76f3ff057..83b6282dd 100644 --- a/src/Examples/flows/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h +++ b/src/Examples/flows/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h @@ -114,8 +114,8 @@ class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, Mesh typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > @@ -245,8 +245,8 @@ class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, Mesh typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -416,8 +416,8 @@ class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, Mesh typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > diff --git a/src/Examples/flows/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h index 188aaa985..9d887857c 100644 --- a/src/Examples/flows/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h +++ b/src/Examples/flows/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h @@ -114,8 +114,8 @@ class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, Mesh typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > @@ -245,8 +245,8 @@ class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, Mesh typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -397,8 +397,8 @@ class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, Mesh typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > diff --git a/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h index 8a42faea1..bbae2d3e9 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h @@ -29,14 +29,14 @@ class BoundaryConditionsCavity typedef TNL::Operators::EnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; - typedef SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; - typedef SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; - typedef SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; - typedef SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshType > MeshPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) diff --git a/src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h b/src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h index a3afc8453..01e820686 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h @@ -13,7 +13,7 @@ #include #include -#include +#include namespace TNL { @@ -28,9 +28,9 @@ class CompressibleConservativeVariables typedef typename MeshType::IndexType IndexType; typedef Functions::MeshFunction< Mesh > MeshFunctionType; typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshType > MeshPointer; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > MomentumFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; CompressibleConservativeVariables(){}; @@ -144,4 +144,4 @@ class CompressibleConservativeVariables }; -} // namespace TN \ No newline at end of file +} // namespace TN diff --git a/src/Examples/flows/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h index 06515a88c..c753d324a 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h @@ -114,8 +114,8 @@ class DensityBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIn typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef DensityBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -237,8 +237,8 @@ class DensityBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIn typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef DensityBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -384,8 +384,8 @@ class DensityBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIn typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef DensityBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > diff --git a/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h index 74ea75a70..6cdbd6a87 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h @@ -12,7 +12,6 @@ #pragma once #include -#include "CompressibleConservativeVariables.h" namespace TNL { namespace Operators { @@ -116,8 +115,8 @@ class EnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshInd typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > @@ -255,8 +254,8 @@ class EnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshInd typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -479,8 +478,8 @@ class EnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshInd typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > diff --git a/src/Examples/flows/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h index b78731382..07abfdbeb 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h @@ -114,8 +114,8 @@ class MomentumXBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, Mesh typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > @@ -245,8 +245,8 @@ class MomentumXBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, Mesh typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -410,8 +410,8 @@ class MomentumXBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, Mesh typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > diff --git a/src/Examples/flows/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h index afce8239b..a83dd653f 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h @@ -114,8 +114,8 @@ class MomentumYBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, Mesh typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > @@ -245,8 +245,8 @@ class MomentumYBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, Mesh typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -407,8 +407,8 @@ class MomentumYBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, Mesh typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > diff --git a/src/Examples/flows/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h index 1942cd589..5fe6f22e5 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h @@ -114,8 +114,8 @@ class MomentumZBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, Mesh typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > @@ -245,8 +245,8 @@ class MomentumZBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, Mesh typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, @@ -397,8 +397,8 @@ class MomentumZBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, Mesh typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; template< typename EntityType, typename MeshFunction > diff --git a/src/Examples/flows/CMakeLists.txt b/src/Examples/flows/CMakeLists.txt index 866861d52..d1ab7b055 100644 --- a/src/Examples/flows/CMakeLists.txt +++ b/src/Examples/flows/CMakeLists.txt @@ -1,29 +1,29 @@ #euler - -set( tnl_inviscid_flow_HEADERS - CompressibleConservativeVariables.h ) - -set( tnl_inviscid_flow_SOURCES - euler.cpp - euler.cu ) - -IF( BUILD_CUDA ) - CUDA_ADD_EXECUTABLE(tnl-euler euler.cu) - target_link_libraries (tnl-euler tnl ${CUSPARSE_LIBRARY} ) -ELSE( BUILD_CUDA ) - ADD_EXECUTABLE(tnl-euler euler.cpp) - target_link_libraries (tnl-euler tnl ) -ENDIF( BUILD_CUDA ) - - -INSTALL( TARGETS tnl-euler - RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) - -INSTALL( FILES run-euler - ${tnl_inviscid_flow_SOURCES} - DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/inviscid-flow ) - +# +#set( tnl_inviscid_flow_HEADERS +# CompressibleConservativeVariables.h ) +# +#set( tnl_inviscid_flow_SOURCES +# euler.cpp +# euler.cu ) +# +#IF( BUILD_CUDA ) +# CUDA_ADD_EXECUTABLE(tnl-euler euler.cu) +# target_link_libraries (tnl-euler tnl ${CUSPARSE_LIBRARY} ) +#ELSE( BUILD_CUDA ) +# ADD_EXECUTABLE(tnl-euler euler.cpp) +# target_link_libraries (tnl-euler tnl ) +#ENDIF( BUILD_CUDA ) +# +# +#INSTALL( TARGETS tnl-euler +# RUNTIME DESTINATION bin +# PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) +# +#INSTALL( FILES run-euler +# ${tnl_inviscid_flow_SOURCES} +# DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/inviscid-flow ) +# #navier-stokes set( tnl_flow_HEADERS @@ -42,7 +42,7 @@ ELSE( BUILD_CUDA ) ENDIF( BUILD_CUDA ) -INSTALL( TARGETS tnl-euler +INSTALL( TARGETS tnl-navier-stokes RUNTIME DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) diff --git a/src/Examples/flows/CompressibleConservativeVariables.h b/src/Examples/flows/CompressibleConservativeVariables.h index a3afc8453..01e820686 100644 --- a/src/Examples/flows/CompressibleConservativeVariables.h +++ b/src/Examples/flows/CompressibleConservativeVariables.h @@ -13,7 +13,7 @@ #include #include -#include +#include namespace TNL { @@ -28,9 +28,9 @@ class CompressibleConservativeVariables typedef typename MeshType::IndexType IndexType; typedef Functions::MeshFunction< Mesh > MeshFunctionType; typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshType > MeshPointer; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > MomentumFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; CompressibleConservativeVariables(){}; @@ -144,4 +144,4 @@ class CompressibleConservativeVariables }; -} // namespace TN \ No newline at end of file +} // namespace TN diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h index ec17a98ae..329cc243c 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h @@ -43,15 +43,15 @@ class LaxFridrichs typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VectorFieldType > VectorFieldPointer; - typedef SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h index 2c1404746..b4836ab74 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace TNL { @@ -34,7 +34,7 @@ class LaxFridrichsContinuityBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; LaxFridrichsContinuityBase() : artificialViscosity( 1.0 ){}; diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h index a3676e506..3bfb98285 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -30,8 +30,8 @@ class LaxFridrichsEnergyBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; LaxFridrichsEnergyBase() : artificialViscosity( 1.0 ){}; diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h index 67dae9fdf..cc2561748 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -28,8 +28,8 @@ class LaxFridrichsMomentumBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; LaxFridrichsMomentumBase() : artificialViscosity( 1.0 ){}; diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h index 6083bbcd0..204ff3059 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h @@ -43,15 +43,15 @@ class StegerWarming typedef StegerWarmingMomentumZ< Mesh, Real, Index > MomentumZOperatorType; typedef StegerWarmingEnergy< Mesh, Real, Index > EnergyOperatorType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VectorFieldType > VectorFieldPointer; - typedef SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h index 0bc097d1f..e64ffd50c 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace TNL { @@ -34,8 +34,8 @@ class StegerWarmingContinuityBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; static String getType() { diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h index 72de3016d..c9c75c9f5 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h @@ -30,8 +30,8 @@ class StegerWarmingEnergyBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; StegerWarmingEnergyBase() : artificialViscosity( 1.0 ){}; diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h index 31009af23..cf95cda18 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h +++ b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h @@ -28,8 +28,8 @@ class StegerWarmingMomentumBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; void setTau(const Real& tau) diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h index 4c3d6112a..eff60cc5b 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h @@ -43,15 +43,15 @@ class VanLeer typedef VanLeerMomentumZ< Mesh, Real, Index > MomentumZOperatorType; typedef VanLeerEnergy< Mesh, Real, Index > EnergyOperatorType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VectorFieldType > VectorFieldPointer; - typedef SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h index 94a40dcbf..e8628ad38 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace TNL { @@ -34,8 +34,8 @@ class VanLeerContinuityBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; static String getType() { diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h index ac933fcb1..b6aa75fa5 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h @@ -30,8 +30,8 @@ class VanLeerEnergyBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; VanLeerEnergyBase() : artificialViscosity( 1.0 ){}; diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h index 5cc23112f..7e6867a3e 100644 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h +++ b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h @@ -28,8 +28,8 @@ class VanLeerMomentumBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; void setTau(const Real& tau) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h index aa370506b..411f41d6f 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h @@ -21,10 +21,12 @@ #include "LaxFridrichsMomentumY.h" #include "LaxFridrichsMomentumZ.h" +#include "Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h" + namespace TNL { template< typename Mesh, - int OperatorRightHandSide = 0, + typename OperatorRightHandSide = NullOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class LaxFridrichs @@ -37,22 +39,28 @@ class LaxFridrichs typedef Functions::MeshFunction< Mesh > MeshFunctionType; static const int Dimensions = Mesh::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; - typedef LaxFridrichsContinuity< Mesh, OperatorRightHandSide, Real, Index > ContinuityOperatorType; - typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VectorFieldType > VectorFieldPointer; - typedef SharedPointer< MeshType > MeshPointer; + typedef LaxFridrichsContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef LaxFridrichsMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef LaxFridrichsMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef LaxFridrichsMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef LaxFridrichsEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h index 21d20479b..e82c9d424 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h @@ -14,12 +14,13 @@ #include #include #include -#include +#include namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class LaxFridrichsContinuityBase @@ -34,7 +35,8 @@ class LaxFridrichsContinuityBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; LaxFridrichsContinuityBase() : artificialViscosity( 1.0 ){}; @@ -68,13 +70,15 @@ class LaxFridrichsContinuityBase RealType tau; VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; RealType artificialViscosity; }; template< typename Mesh, - int OperatorRightHandSide = 0, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class LaxFridrichsContinuity @@ -86,15 +90,15 @@ class LaxFridrichsContinuity template< typename MeshReal, typename Device, typename MeshIndex, - int OperatorRightHandSide, + typename OperatorRightHandSide, typename Real, typename Index > class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -105,12 +109,6 @@ class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Op using typename BaseType::VelocityFieldPointer; using BaseType::Dimensions; -/* template < int OperatorRHS > - __cuda_callable__ - Real rightHandSide() - { - }*/ - template< typename MeshFunction, typename MeshEntity > __cuda_callable__ Real operator()( const MeshFunction& u, @@ -133,8 +131,9 @@ class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Op // return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) // - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) - - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; - //+ rightHandSide(); + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -154,43 +153,19 @@ class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Op Vector& b, MatrixRow& matrixRow ) const;*/ }; -/* -template< typename MeshReal, - typename Device, - typename MeshIndex, - int OperatorRightHandSide, - typename Real, - typename Index > - template<> //Euler -__cuda_callable__ -Real -LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index >:: -rightHandSide<1>() - { - return 0; - } -/* - template<> //Navier-Stokes - __cuda_callable__ - RealType rightHandSide<1>() - { - return 0; - } -*/ - template< typename MeshReal, typename Device, typename MeshIndex, - int OperatorRightHandSide, + typename OperatorRightHandSide, typename Real, typename Index > class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -228,7 +203,9 @@ class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Op return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ); + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ) + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -252,15 +229,15 @@ class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Op template< typename MeshReal, typename Device, typename MeshIndex, - int OperatorRightHandSide, + typename OperatorRightHandSide, typename Real, typename Index > class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -305,7 +282,9 @@ class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Op ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse - + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ); + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ) + + + this->rightHandSide(u, entity, time); } diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h index 950898fab..bed0b9a3f 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -16,6 +16,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class LaxFridrichsEnergyBase @@ -30,8 +31,9 @@ class LaxFridrichsEnergyBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; LaxFridrichsEnergyBase() : artificialViscosity( 1.0 ){}; @@ -52,6 +54,7 @@ class LaxFridrichsEnergyBase void setVelocity( const VelocityFieldPointer& velocity ) { this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); }; void setPressure( const MeshFunctionPointer& pressure ) @@ -67,6 +70,7 @@ class LaxFridrichsEnergyBase void setDynamicalViscosity( const RealType& dynamicalViscosity ) { this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); } protected: @@ -74,6 +78,8 @@ class LaxFridrichsEnergyBase RealType tau; VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; MeshFunctionPointer pressure; @@ -81,6 +87,7 @@ class LaxFridrichsEnergyBase }; template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class LaxFridrichsEnergy @@ -90,15 +97,16 @@ class LaxFridrichsEnergy template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -138,11 +146,8 @@ class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse -// 1D uT_11_x - - 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse / 4 - * this->dynamicalViscosity; + + + this->rightHandSide(e, entity, time); } /*template< typename MeshEntity > @@ -166,14 +171,15 @@ class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -242,38 +248,8 @@ class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ) -// 2D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - - velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 2D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_east - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity; + + + this->rightHandSide(e, entity, time); } /*template< typename MeshEntity > @@ -297,14 +273,15 @@ class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -417,87 +394,8 @@ class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ) -// 3D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east - - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// wT_31_x - + ( ( velocity_z_upEast * velocity_z_east - velocity_z_downEast * velocity_z_east - - velocity_z_upWest * velocity_z_west + velocity_z_downWest * velocity_z_west - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east * velocity_z_center - velocity_x_center * velocity_z_west - - velocity_x_center * velocity_z_center + velocity_x_west * velocity_z_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - + velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// wT_32_y - + ( ( velocity_z_upNorth * velocity_z_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_z_south + velocity_z_downSouth * velocity_z_south - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north * velocity_z_center - velocity_y_center * velocity_z_south - - velocity_y_center * velocity_z_center + velocity_y_south * velocity_z_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// uT_13_z - + ( ( velocity_z_up * velocity_x_center - velocity_z_center * velocity_x_center - - velocity_z_center * velocity_x_down + velocity_z_down * velocity_x_down - ) * hzSquareInverse - + ( velocity_x_upEast * velocity_x_up - velocity_x_downEast * velocity_x_down - - velocity_x_upWest * velocity_x_up + velocity_x_downWest * velocity_x_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth * velocity_y_up - velocity_y_downNorth * velocity_y_down - - velocity_y_upSouth * velocity_y_up + velocity_y_downSouth * velocity_y_down - ) * hyInverse * hzInverse / 4 - + ( velocity_z_up * velocity_y_center - velocity_z_center * velocity_y_down - - velocity_z_center * velocity_y_center + velocity_z_down * velocity_y_down - ) * hzSquareInverse - ) * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down - - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down - ) * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down - - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down - ) * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down - - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity; + + + this->rightHandSide(e, entity, time); } /*template< typename MeshEntity > diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h index 5f02acfe2..a439f0aa7 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -14,6 +14,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class LaxFridrichsMomentumBase @@ -28,8 +29,9 @@ class LaxFridrichsMomentumBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; LaxFridrichsMomentumBase() : artificialViscosity( 1.0 ){}; @@ -42,6 +44,7 @@ class LaxFridrichsMomentumBase void setVelocity( const VelocityFieldPointer& velocity ) { this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); }; void setPressure( const MeshFunctionPointer& pressure ) @@ -57,6 +60,7 @@ class LaxFridrichsMomentumBase void setDynamicalViscosity( const RealType& dynamicalViscosity ) { this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); } protected: @@ -64,6 +68,8 @@ class LaxFridrichsMomentumBase RealType tau; VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; MeshFunctionPointer pressure; diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h index f2afe8d4b..07780e7bd 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h @@ -18,6 +18,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class LaxFridrichsMomentumX @@ -27,15 +28,16 @@ class LaxFridrichsMomentumX template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -84,10 +86,8 @@ class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Rea return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse -// 1D T_11_x - - 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - * this->dynamicalViscosity; + + + this->rightHandSide(rho_u, entity, time); } /*template< typename MeshEntity > @@ -111,14 +111,15 @@ class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Rea template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -191,18 +192,8 @@ class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse + ( ( rho_u[ north ] * velocity_y_north ) - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ) -// 2D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_21_y - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south - ) * hxInverse * hyInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(rho_u, entity, time); } /*template< typename MeshEntity > @@ -226,14 +217,15 @@ class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -341,26 +333,8 @@ class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real - ( rho_u[ south ] * velocity_y_south ) )* hyInverse + ( ( rho_u[ up ] * velocity_z_up ) - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ) -// 3D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_21_x - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// T_31_x - + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(rho_u, entity, time); } /*template< typename MeshEntity > diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h index b61415cd2..73a789372 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h @@ -18,6 +18,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class LaxFridrichsMomentumY @@ -27,15 +28,16 @@ class LaxFridrichsMomentumY template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -90,14 +92,15 @@ class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Rea template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -171,18 +174,8 @@ class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea - ( rho_v[ west ] * velocity_x_west ) )* hxInverse + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ) -// 2D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_12_x - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east - ) * hxSquareInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(rho_v, entity, time); } /*template< typename MeshEntity > @@ -206,14 +199,15 @@ class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -321,26 +315,8 @@ class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse + ( ( rho_v[ up ] * velocity_z_up ) - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ) -// T_12_y - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_32_y - + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(rho_v, entity, time); } /*template< typename MeshEntity > diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h index 51f51734e..cac36283b 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h @@ -18,6 +18,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class LaxFridrichsMomentumZ @@ -27,15 +28,16 @@ class LaxFridrichsMomentumZ template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -90,14 +92,15 @@ class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Rea template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -151,14 +154,15 @@ class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Rea template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -267,29 +271,8 @@ class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real - ( rho_w[ south ] * velocity_y_south ) )* hyInverse + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ) -// T_13_z - + ( ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - + ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - ) - * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity; + + + this->rightHandSide(rho_w, entity, time); } /*template< typename MeshEntity > diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h index 510dfecaf..0f36447ef 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h @@ -21,9 +21,12 @@ #include "StegerWarmingMomentumY.h" #include "StegerWarmingMomentumZ.h" +#include "Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h" + namespace TNL { template< typename Mesh, + typename OperatorRightHandSide = NullOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class StegerWarming @@ -36,22 +39,28 @@ class StegerWarming typedef Functions::MeshFunction< Mesh > MeshFunctionType; static const int Dimensions = Mesh::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; - typedef StegerWarmingContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef StegerWarmingMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef StegerWarmingMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef StegerWarmingMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef StegerWarmingEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VectorFieldType > VectorFieldPointer; - typedef SharedPointer< MeshType > MeshPointer; + typedef StegerWarmingContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef StegerWarmingMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef StegerWarmingMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef StegerWarmingMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef StegerWarmingEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h index 004def45f..0903fd632 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h @@ -14,12 +14,13 @@ #include #include #include -#include +#include namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class StegerWarmingContinuityBase @@ -34,8 +35,9 @@ class StegerWarmingContinuityBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; static String getType() { @@ -107,12 +109,15 @@ class StegerWarmingContinuityBase VelocityFieldPointer velocity; + OperatorRightHandSideType rightHandSide; + MeshFunctionPointer pressure; }; template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class StegerWarmingContinuity @@ -124,14 +129,15 @@ class StegerWarmingContinuity template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -171,7 +177,9 @@ class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, R - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ); + ) + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -195,14 +203,15 @@ class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, R template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -258,7 +267,9 @@ class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, R - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ); + ) + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -282,14 +293,15 @@ class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, R template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -360,7 +372,9 @@ class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, R - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) - ); + ) + + + this->rightHandSide(u, entity, time); } diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h index 824573476..e1ed377db 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h @@ -16,6 +16,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class StegerWarmingEnergyBase @@ -30,8 +31,9 @@ class StegerWarmingEnergyBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; StegerWarmingEnergyBase() : artificialViscosity( 1.0 ){}; @@ -57,6 +59,7 @@ class StegerWarmingEnergyBase void setVelocity( const VelocityFieldPointer& velocity ) { this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); }; void setPressure( const MeshFunctionPointer& pressure ) @@ -77,6 +80,7 @@ class StegerWarmingEnergyBase void setDynamicalViscosity( const RealType& dynamicalViscosity ) { this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); } protected: @@ -86,6 +90,8 @@ class StegerWarmingEnergyBase RealType gamma; VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; MeshFunctionPointer pressure; @@ -95,6 +101,7 @@ class StegerWarmingEnergyBase }; template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class StegerWarmingEnergy @@ -104,15 +111,16 @@ class StegerWarmingEnergy template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -208,11 +216,8 @@ class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) ) -// 1D uT_11_x - - 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse / 4 - * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } @@ -237,14 +242,15 @@ class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -374,38 +380,8 @@ class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) ) -// 2D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - - velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 2D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_east - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -429,14 +405,15 @@ class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -616,87 +593,8 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) ) -// 3D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east - - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// wT_31_x - + ( ( velocity_z_upEast * velocity_z_east - velocity_z_downEast * velocity_z_east - - velocity_z_upWest * velocity_z_west + velocity_z_downWest * velocity_z_west - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east * velocity_z_center - velocity_x_center * velocity_z_west - - velocity_x_center * velocity_z_center + velocity_x_west * velocity_z_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - + velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// wT_32_y - + ( ( velocity_z_upNorth * velocity_z_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_z_south + velocity_z_downSouth * velocity_z_south - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north * velocity_z_center - velocity_y_center * velocity_z_south - - velocity_y_center * velocity_z_center + velocity_y_south * velocity_z_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// uT_13_z - + ( ( velocity_z_up * velocity_x_center - velocity_z_center * velocity_x_center - - velocity_z_center * velocity_x_down + velocity_z_down * velocity_x_down - ) * hzSquareInverse - + ( velocity_x_upEast * velocity_x_up - velocity_x_downEast * velocity_x_down - - velocity_x_upWest * velocity_x_up + velocity_x_downWest * velocity_x_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth * velocity_y_up - velocity_y_downNorth * velocity_y_down - - velocity_y_upSouth * velocity_y_up + velocity_y_downSouth * velocity_y_down - ) * hyInverse * hzInverse / 4 - + ( velocity_z_up * velocity_y_center - velocity_z_center * velocity_y_down - - velocity_z_center * velocity_y_center + velocity_z_down * velocity_y_down - ) * hzSquareInverse - ) * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down - - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down - ) * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down - - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down - ) * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down - - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h index 3b0f0b89b..98e7b8b7f 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h @@ -14,6 +14,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class StegerWarmingMomentumBase @@ -28,8 +29,9 @@ class StegerWarmingMomentumBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; void setTau(const Real& tau) @@ -45,6 +47,7 @@ class StegerWarmingMomentumBase void setVelocity( const VelocityFieldPointer& velocity ) { this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); }; void setDensity( const MeshFunctionPointer& density ) @@ -60,6 +63,7 @@ class StegerWarmingMomentumBase void setDynamicalViscosity( const RealType& dynamicalViscosity ) { this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); } RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const @@ -125,6 +129,8 @@ class StegerWarmingMomentumBase RealType gamma; VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; MeshFunctionPointer pressure; diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h index d3d8e5695..4b729d5bd 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h @@ -18,6 +18,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class StegerWarmingMomentumX @@ -27,15 +28,16 @@ class StegerWarmingMomentumX template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -92,10 +94,8 @@ class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Re - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) ) -// 1D T_11_x - - 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -119,14 +119,15 @@ class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Re template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -215,18 +216,8 @@ class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) ) -// 2D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_21_y - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south - ) * hxInverse * hyInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } @@ -252,14 +243,15 @@ class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -391,26 +383,8 @@ class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) ) -// 3D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_21_x - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// T_31_x - + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h index c3daa16e9..a71422df5 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h @@ -18,6 +18,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class StegerWarmingMomentumY @@ -27,15 +28,16 @@ class StegerWarmingMomentumY template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -90,14 +92,15 @@ class StegerWarmingMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Re template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -186,18 +189,8 @@ class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) ) -// 2D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_12_x - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east - ) * hxSquareInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -221,14 +214,15 @@ class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -360,26 +354,8 @@ class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) ) -// T_12_y - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_32_y - + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h index 8c9f29a28..748e9b1b3 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h @@ -18,6 +18,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class StegerWarmingMomentumZ @@ -27,15 +28,16 @@ class StegerWarmingMomentumZ template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -90,14 +92,15 @@ class StegerWarmingMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Re template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -151,14 +154,15 @@ class StegerWarmingMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Re template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -290,29 +294,8 @@ class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Rea - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) ) -// T_13_z - + ( ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - + ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - ) - * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h index 3d47a09be..1bf447399 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h @@ -43,15 +43,15 @@ class VanLeer typedef VanLeerMomentumZ< Mesh, Real, Index > MomentumZOperatorType; typedef VanLeerEnergy< Mesh, Real, Index > EnergyOperatorType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VectorFieldType > VectorFieldPointer; - typedef SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; static void configSetup( Config::ConfigDescription& config, const String& prefix = "" ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h index c105b8a83..2bcde13d2 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace TNL { @@ -34,8 +34,8 @@ class VanLeerContinuityBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; static String getType() { diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h index 698d1625d..2a23060cf 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h @@ -30,8 +30,8 @@ class VanLeerEnergyBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; VanLeerEnergyBase() : artificialViscosity( 1.0 ){}; diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h index 50b0349a5..d4ac78f3b 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h @@ -28,8 +28,8 @@ class VanLeerMomentumBase typedef Functions::MeshFunction< MeshType > MeshFunctionType; static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; void setTau(const Real& tau) diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesContinuityOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesContinuityOperatorRightHandSide.h new file mode 100644 index 000000000..8c46746ef --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesContinuityOperatorRightHandSide.h @@ -0,0 +1,218 @@ +/*************************************************************************** + NavierStokesContinuityOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class NavierStokesContinuityRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + protected: + +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class NavierStokesContinuityRightHandSide +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesContinuityRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesContinuityRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesContinuityRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesContinuityRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesContinuityRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesContinuityRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + + return 0; + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h new file mode 100644 index 000000000..e04861e74 --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h @@ -0,0 +1,474 @@ +/*************************************************************************** + NavierStokesEnergyOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class NavierStokesEnergyRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + NavierStokesEnergyRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + protected: + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class NavierStokesEnergyRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesEnergyRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return +// 1D uT_11_x + 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse / 4 + * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesEnergyRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return +// 2D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// vT_21_x + + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east + - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west + - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_12_y + + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south + - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south + - velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 2D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesEnergyRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east + - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// vT_21_x + + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east + - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west + - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// wT_31_x + + ( ( velocity_z_upEast * velocity_z_east - velocity_z_downEast * velocity_z_east + - velocity_z_upWest * velocity_z_west + velocity_z_downWest * velocity_z_west + ) * hxInverse * hzInverse / 4 + + ( velocity_x_east * velocity_z_center - velocity_x_center * velocity_z_west + - velocity_x_center * velocity_z_center + velocity_x_west * velocity_z_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_12_y + + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south + - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south + + velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// wT_32_y + + ( ( velocity_z_upNorth * velocity_z_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_z_south + velocity_z_downSouth * velocity_z_south + ) * hyInverse * hzInverse / 4 + + ( velocity_y_north * velocity_z_center - velocity_y_center * velocity_z_south + - velocity_y_center * velocity_z_center + velocity_y_south * velocity_z_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// uT_13_z + + ( ( velocity_z_up * velocity_x_center - velocity_z_center * velocity_x_center + - velocity_z_center * velocity_x_down + velocity_z_down * velocity_x_down + ) * hzSquareInverse + + ( velocity_x_upEast * velocity_x_up - velocity_x_downEast * velocity_x_down + - velocity_x_upWest * velocity_x_up + velocity_x_downWest * velocity_x_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_23_z + + ( ( velocity_y_upNorth * velocity_y_up - velocity_y_downNorth * velocity_y_down + - velocity_y_upSouth * velocity_y_up + velocity_y_downSouth * velocity_y_down + ) * hyInverse * hzInverse / 4 + + ( velocity_z_up * velocity_y_center - velocity_z_center * velocity_y_down + - velocity_z_center * velocity_y_center + velocity_z_down * velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down + - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down + - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down + - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumBaseOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumBaseOperatorRightHandSide.h new file mode 100644 index 000000000..9951441b1 --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumBaseOperatorRightHandSide.h @@ -0,0 +1,54 @@ +/*************************************************************************** + NavierStokesMomentumRightHandSideBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class NavierStokesMomentumRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + NavierStokesMomentumRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + protected: + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumXOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumXOperatorRightHandSide.h new file mode 100644 index 000000000..ba1accaf4 --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumXOperatorRightHandSide.h @@ -0,0 +1,358 @@ +/*************************************************************************** + NavierStokesMomentumXRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "NavierStokesMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class NavierStokesMomentumXRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesMomentumXRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return +// 1D T_11_x + 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return +// 2D T_11_x + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hxInverse * hyInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D T_11_x + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_21_x + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// T_31_x + + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumYOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumYOperatorRightHandSide.h new file mode 100644 index 000000000..b6a0e4467 --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumYOperatorRightHandSide.h @@ -0,0 +1,345 @@ +/*************************************************************************** + NavierStokesMomentumYRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "NavierStokesMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class NavierStokesMomentumYRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesMomentumYRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesMomentumYRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + + return +// 2D T_22_y + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_12_x + + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east + ) * hxSquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesMomentumYRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// T_12_y + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D T_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_y + + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + ) * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumZOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumZOperatorRightHandSide.h new file mode 100644 index 000000000..688101700 --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumZOperatorRightHandSide.h @@ -0,0 +1,301 @@ +/*************************************************************************** + NavierStokesMomentumZRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "NavierStokesMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class NavierStokesMomentumZRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesMomentumZRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesMomentumZRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class NavierStokesMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public NavierStokesMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef NavierStokesMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// T_13_z + ( ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// T_23_z + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + ) + * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h new file mode 100644 index 000000000..fdfb7ed8a --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h @@ -0,0 +1,122 @@ +/*************************************************************************** + NavierStokesOpratorRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "NavierStokesContinuityOperatorRightHandSide.h" +#include "NavierStokesEnergyOperatorRightHandSide.h" +#include "NavierStokesMomentumXOperatorRightHandSide.h" +#include "NavierStokesMomentumYOperatorRightHandSide.h" +#include "NavierStokesMomentumZOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class NavierStokesOperatorRightHandSide +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef NavierStokesContinuityRightHandSide< Mesh, Real, Index > ContinuityOperatorRightHandSideType; + typedef NavierStokesMomentumXRightHandSide< Mesh, Real, Index > MomentumXOperatorRightHandSideType; + typedef NavierStokesMomentumYRightHandSide< Mesh, Real, Index > MomentumYOperatorRightHandSideType; + typedef NavierStokesMomentumZRightHandSide< Mesh, Real, Index > MomentumZOperatorRightHandSideType; + typedef NavierStokesEnergyRightHandSide< Mesh, Real, Index > EnergyOperatorRightHandSideType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorRightHandSideType > ContinuityOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumXOperatorRightHandSideType > MomentumXOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumYOperatorRightHandSideType > MomentumYOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumZOperatorRightHandSideType > MomentumZOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< EnergyOperatorRightHandSideType > EnergyOperatorRightHandSidePointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + NavierStokesOperatorRightHandSide() + : dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + return true; + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumXOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumYOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumZOperatorRightHandSidePointer->setVelocity( velocity ); + this->energyOperatorRightHandSidePointer->setVelocity( velocity ); + } + + const ContinuityOperatorRightHandSidePointer& getContinuityOperatorRightHandSide() const + { + return this->continuityOperatorRightHandSidePointer; + } + + const MomentumXOperatorRightHandSidePointer& getMomentumXOperatorRightHandSide() const + { + return this->momentumXOperatorRightHandSidePointer; + } + + const MomentumYOperatorRightHandSidePointer& getMomentumYOperatorRightHandSide() const + { + return this->momentumYOperatorRightHandSidePointer; + } + + const MomentumZOperatorRightHandSidePointer& getMomentumZOperatorRightHandSide() const + { + return this->momentumZOperatorRightHandSidePointer; + } + + const EnergyOperatorRightHandSidePointer& getEnergyOperatorRightHandSide() const + { + return this->energyOperatorRightHandSidePointer; + } + + protected: + + ContinuityOperatorRightHandSidePointer continuityOperatorPointer; + MomentumXOperatorRightHandSidePointer momentumXOperatorPointer; + MomentumYOperatorRightHandSidePointer momentumYOperatorPointer; + MomentumZOperatorRightHandSidePointer momentumZOperatorPointer; + EnergyOperatorRightHandSidePointer energyOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullContinuityOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullContinuityOperatorRightHandSide.h new file mode 100644 index 000000000..2a7eee73f --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullContinuityOperatorRightHandSide.h @@ -0,0 +1,218 @@ +/*************************************************************************** + nullContinuityOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class nullContinuityRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + protected: + +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class nullContinuityRightHandSide +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullContinuityRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public nullContinuityRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef nullContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullContinuityRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public nullContinuityRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef nullContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullContinuityRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public nullContinuityRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef nullContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + + return 0; + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullEnergyOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullEnergyOperatorRightHandSide.h new file mode 100644 index 000000000..8badc0518 --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullEnergyOperatorRightHandSide.h @@ -0,0 +1,229 @@ +/*************************************************************************** + nullEnergyOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class nullEnergyRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + nullEnergyRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + protected: + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class nullEnergyRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public nullEnergyRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef nullEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public nullEnergyRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef nullEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public nullEnergyRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef nullEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumBaseOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumBaseOperatorRightHandSide.h new file mode 100644 index 000000000..a24c7a764 --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumBaseOperatorRightHandSide.h @@ -0,0 +1,54 @@ +/*************************************************************************** + nullMomentumRightHandSideBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class nullMomentumRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + nullMomentumRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + protected: + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumXOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumXOperatorRightHandSide.h new file mode 100644 index 000000000..81bcad971 --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumXOperatorRightHandSide.h @@ -0,0 +1,211 @@ +/*************************************************************************** + nullMomentumXRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "nullMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class nullMomentumXRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullMomentumXRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public nullMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef nullMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public nullMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef nullMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public nullMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef nullMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumYOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumYOperatorRightHandSide.h new file mode 100644 index 000000000..6aa0680e3 --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumYOperatorRightHandSide.h @@ -0,0 +1,213 @@ +/*************************************************************************** + nullMomentumYRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "nullMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class nullMomentumYRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullMomentumYRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public nullMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef nullMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullMomentumYRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public nullMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef nullMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullMomentumYRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public nullMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef nullMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumZOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumZOperatorRightHandSide.h new file mode 100644 index 000000000..a6be207b4 --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullMomentumZOperatorRightHandSide.h @@ -0,0 +1,212 @@ +/*************************************************************************** + nullMomentumZRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "nullMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class nullMomentumZRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullMomentumZRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public nullMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef nullMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullMomentumZRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public nullMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef nullMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class nullMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public nullMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef nullMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h new file mode 100644 index 000000000..00faf9881 --- /dev/null +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h @@ -0,0 +1,122 @@ +/*************************************************************************** + nullOpratorRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "nullContinuityOperatorRightHandSide.h" +#include "nullEnergyOperatorRightHandSide.h" +#include "nullMomentumXOperatorRightHandSide.h" +#include "nullMomentumYOperatorRightHandSide.h" +#include "nullMomentumZOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class NullOperatorRightHandSide +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef nullContinuityRightHandSide< Mesh, Real, Index > ContinuityOperatorRightHandSideType; + typedef nullMomentumXRightHandSide< Mesh, Real, Index > MomentumXOperatorRightHandSideType; + typedef nullMomentumYRightHandSide< Mesh, Real, Index > MomentumYOperatorRightHandSideType; + typedef nullMomentumZRightHandSide< Mesh, Real, Index > MomentumZOperatorRightHandSideType; + typedef nullEnergyRightHandSide< Mesh, Real, Index > EnergyOperatorRightHandSideType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorRightHandSideType > ContinuityOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumXOperatorRightHandSideType > MomentumXOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumYOperatorRightHandSideType > MomentumYOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumZOperatorRightHandSideType > MomentumZOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< EnergyOperatorRightHandSideType > EnergyOperatorRightHandSidePointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + NullOperatorRightHandSide() + : dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + return true; + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumXOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumYOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumZOperatorRightHandSidePointer->setVelocity( velocity ); + this->energyOperatorRightHandSidePointer->setVelocity( velocity ); + } + + const ContinuityOperatorRightHandSidePointer& getContinuityOperatorRightHandSide() const + { + return this->continuityOperatorRightHandSidePointer; + } + + const MomentumXOperatorRightHandSidePointer& getMomentumXOperatorRightHandSide() const + { + return this->momentumXOperatorRightHandSidePointer; + } + + const MomentumYOperatorRightHandSidePointer& getMomentumYOperatorRightHandSide() const + { + return this->momentumYOperatorRightHandSidePointer; + } + + const MomentumZOperatorRightHandSidePointer& getMomentumZOperatorRightHandSide() const + { + return this->momentumZOperatorRightHandSidePointer; + } + + const EnergyOperatorRightHandSidePointer& getEnergyOperatorRightHandSide() const + { + return this->energyOperatorRightHandSidePointer; + } + + protected: + + ContinuityOperatorRightHandSidePointer continuityOperatorPointer; + MomentumXOperatorRightHandSidePointer momentumXOperatorPointer; + MomentumYOperatorRightHandSidePointer momentumYOperatorPointer; + MomentumZOperatorRightHandSidePointer momentumZOperatorPointer; + EnergyOperatorRightHandSidePointer energyOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/PhysicalVariablesGetter.h b/src/Examples/flows/PhysicalVariablesGetter.h index f1ba6bd12..2af0a02b8 100644 --- a/src/Examples/flows/PhysicalVariablesGetter.h +++ b/src/Examples/flows/PhysicalVariablesGetter.h @@ -10,7 +10,7 @@ #pragma once -#include +#include #include #include #include @@ -30,11 +30,11 @@ class PhysicalVariablesGetter static const int Dimensions = MeshType::getMeshDimension(); typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > { @@ -99,7 +99,7 @@ class PhysicalVariablesGetter Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; for( int i = 0; i < Dimensions; i++ ) { - SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), + Pointers::SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), ( *conservativeVariables->getMomentum() )[ i ] ); evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); } @@ -110,7 +110,7 @@ class PhysicalVariablesGetter MeshFunctionPointer& pressure ) { Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; - SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), + Pointers::SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), conservativeVariables->getEnergy(), conservativeVariables->getMomentum(), gamma ); diff --git a/src/Examples/flows/RiemannProblemInitialCondition.h b/src/Examples/flows/RiemannProblemInitialCondition.h index b1819b1eb..5414fcd6d 100644 --- a/src/Examples/flows/RiemannProblemInitialCondition.h +++ b/src/Examples/flows/RiemannProblemInitialCondition.h @@ -38,7 +38,7 @@ class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, Me static const int Dimensions = MeshType::getMeshDimension(); typedef Containers::StaticVector< Dimensions, RealType > PointType; typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; // for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() // typedef typename MeshType::Cell CellType @@ -195,7 +195,7 @@ class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, M static const int Dimensions = MeshType::getMeshDimension(); typedef Containers::StaticVector< Dimensions, RealType > PointType; typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; // for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() // typedef typename MeshType::Cell CellType @@ -415,7 +415,7 @@ class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, M static const int Dimensions = MeshType::getMeshDimension(); typedef Containers::StaticVector< Dimensions, RealType > PointType; typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; // for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() // typedef typename MeshType::Cell CellType @@ -768,7 +768,7 @@ class RiemannProblemInitialCondition static const int Dimensions = MeshType::getMeshDimension(); typedef Containers::StaticVector< Dimensions, RealType > PointType; typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; RiemannProblemInitialCondition() diff --git a/src/Examples/flows/eulerProblem.h b/src/Examples/flows/eulerProblem.h index cb24108ef..bf1d6f3d0 100644 --- a/src/Examples/flows/eulerProblem.h +++ b/src/Examples/flows/eulerProblem.h @@ -49,12 +49,13 @@ class eulerProblem: typedef Functions::MeshFunction< Mesh > MeshFunctionType; typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - typedef SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; - typedef SharedPointer< InviscidOperators > InviscidOperatorsPointer; - typedef SharedPointer< BoundaryCondition > BoundaryConditionPointer; - typedef SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; + typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; + typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; + static String getType(); diff --git a/src/Examples/flows/navierStokes.h b/src/Examples/flows/navierStokes.h index e9deffed6..884bf11f4 100644 --- a/src/Examples/flows/navierStokes.h +++ b/src/Examples/flows/navierStokes.h @@ -14,6 +14,8 @@ #include "RiemannProblemInitialCondition.h" #include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" #include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h" +#include "DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h" using namespace TNL; @@ -42,6 +44,9 @@ template< typename ConfigTag >class navierStokesConfig config.addEntryEnum< String >( "Lax-Friedrichs" ); config.addEntryEnum< String >( "Steger-Warming" ); config.addEntryEnum< String >( "VanLeer" ); + config.addEntry< String >( "oprator-right-hand-side", "Choose equation type.", "Euler"); + config.addEntryEnum< String >( "Euler" ); + config.addEntryEnum< String >( "Navier-Stokes" ); config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); @@ -75,14 +80,20 @@ class navierStokesSetter static bool run( const Config::ParameterContainer & parameters ) { enum { Dimension = MeshType::getMeshDimension() }; - typedef LaxFridrichs< MeshType, 0, Real, Index > ApproximateOperator; + typedef NullOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; typedef flowsRhs< MeshType, Real > RightHandSide; typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + String operatorRightHandSideType = parameters.getParameter< String >( "operator-right-hand-side"); + if( operatorRightHandSideType == "Euler" ) + typedef NullOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + else if( operatorRightHandSideType == "Navier-Stokes" ) + typedef NavierStokesOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); if( differentialOperatorType == "Lax-Friedrichs" ) - typedef LaxFridrichs< MeshType, 0, Real, Index > ApproximateOperator; + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; else if( differentialOperatorType == "Steger-Warming" ) - typedef StegerWarming< MeshType, Real, Index > ApproximateOperator; + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; else if( differentialOperatorType == "VanLeer" ) typedef VanLeer< MeshType, Real, Index > ApproximateOperator; diff --git a/src/Examples/flows/navierStokesProblem.h b/src/Examples/flows/navierStokesProblem.h index 882de7491..e195513fa 100644 --- a/src/Examples/flows/navierStokesProblem.h +++ b/src/Examples/flows/navierStokesProblem.h @@ -49,12 +49,12 @@ class navierStokesProblem: typedef Functions::MeshFunction< Mesh > MeshFunctionType; typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - typedef SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef SharedPointer< VelocityFieldType > VelocityFieldPointer; - typedef SharedPointer< InviscidOperators > InviscidOperatorsPointer; - typedef SharedPointer< BoundaryCondition > BoundaryConditionPointer; - typedef SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; + typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; + typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; static String getType(); -- GitLab From 2e559458705cae8b8ec00f6f58955a11a84fa4a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Thu, 1 Nov 2018 08:29:59 +0100 Subject: [PATCH 05/28] all dif. operator and boundary conditions unified in flows --- .../Cavity/BoundaryConditionsCavity.h | 1 + .../Cavity/EnergyBoundaryConditionCavity.h | 1 + .../Lax-Friedrichs/LaxFridrichsEnergy.h | 92 +---------- .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 3 +- .../Lax-Friedrichs/LaxFridrichsMomentumX.h | 69 +------- .../Lax-Friedrichs/LaxFridrichsMomentumY.h | 70 +------- .../Lax-Friedrichs/LaxFridrichsMomentumZ.h | 51 +----- .../Steger-Warming/StegerWarmingContinuity.h | 4 - .../Steger-Warming/StegerWarmingEnergy.h | 74 +-------- .../StegerWarmingMomentumBase.h | 3 - .../Steger-Warming/StegerWarmingMomentumX.h | 58 +------ .../Steger-Warming/StegerWarmingMomentumY.h | 61 +------ .../Steger-Warming/StegerWarmingMomentumZ.h | 42 +---- .../Navier-Stokes/VanLeer/VanLeer.h | 19 ++- .../Navier-Stokes/VanLeer/VanLeerContinuity.h | 38 +++-- .../Navier-Stokes/VanLeer/VanLeerEnergy.h | 152 +++--------------- .../VanLeer/VanLeerMomentumBase.h | 6 + .../Navier-Stokes/VanLeer/VanLeerMomentumX.h | 64 +++----- .../Navier-Stokes/VanLeer/VanLeerMomentumY.h | 58 ++----- .../Navier-Stokes/VanLeer/VanLeerMomentumZ.h | 47 ++---- .../flows/RiemannProblemInitialCondition.h | 2 +- src/Examples/flows/flowsBuildConfigTag.h | 2 +- src/Examples/flows/navierStokes.h | 26 ++- src/Examples/flows/navierStokesProblem.h | 4 + src/Examples/flows/navierStokesProblem_impl.h | 4 +- src/TNL/Solvers/PDE/ExplicitUpdater.h | 2 +- 26 files changed, 180 insertions(+), 773 deletions(-) diff --git a/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h index bbae2d3e9..a6e7424ca 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h @@ -93,6 +93,7 @@ class BoundaryConditionsCavity void setSpeed(const RealType cavitySpeed) { + cout <<"setSpeed" << endl; this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); diff --git a/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h index 6cdbd6a87..a302ab147 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h @@ -268,6 +268,7 @@ class EnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshInd const MeshType& mesh = entity.getMesh(); const auto& neighborEntities = entity.getNeighborEntities(); const IndexType& index = entity.getIndex(); + cout << "energy" << endl; if( entity.getCoordinates().x() == 0 ) { return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h index bed0b9a3f..0732aaf5c 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -69,7 +69,6 @@ class LaxFridrichsEnergyBase void setDynamicalViscosity( const RealType& dynamicalViscosity ) { - this->dynamicalViscosity = dynamicalViscosity; this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); } @@ -83,7 +82,7 @@ class LaxFridrichsEnergyBase MeshFunctionPointer pressure; - RealType artificialViscosity, dynamicalViscosity; + RealType artificialViscosity; }; template< typename Mesh, @@ -130,8 +129,6 @@ class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Operat const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); - const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); @@ -141,7 +138,6 @@ class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Operat const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east @@ -205,43 +201,22 @@ class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operat const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) @@ -307,10 +282,6 @@ class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Operat const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); @@ -318,18 +289,6 @@ class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Operat const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; @@ -337,54 +296,15 @@ class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Operat const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h index a439f0aa7..5fe1b6598 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -59,7 +59,6 @@ class LaxFridrichsMomentumBase void setDynamicalViscosity( const RealType& dynamicalViscosity ) { - this->dynamicalViscosity = dynamicalViscosity; this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); } @@ -73,7 +72,7 @@ class LaxFridrichsMomentumBase MeshFunctionPointer pressure; - RealType artificialViscosity, dynamicalViscosity; + RealType artificialViscosity; }; } //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h index 07780e7bd..57258d1a5 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h @@ -69,8 +69,6 @@ class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Ope const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); @@ -81,7 +79,6 @@ class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Ope const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) @@ -161,31 +158,15 @@ class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Ope const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) @@ -259,10 +240,6 @@ class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Oper const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); @@ -270,60 +247,18 @@ class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Oper const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h index 73a789372..4cca02779 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h @@ -132,41 +132,22 @@ class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Ope const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) @@ -251,61 +232,18 @@ class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Oper const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h index cac36283b..1f394bfef 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h @@ -196,10 +196,6 @@ class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Oper const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); @@ -207,61 +203,18 @@ class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Oper const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h index 0903fd632..e42c8d592 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h @@ -95,10 +95,6 @@ class StegerWarmingContinuityBase return 0.0; }; - RealType multiply (const RealType& a, const RealType& b ) const - { - return a * b; - }; protected: diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h index e1ed377db..042222d27 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h @@ -35,9 +35,6 @@ class StegerWarmingEnergyBase typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; typedef OperatorRightHandSide OperatorRightHandSideType; - StegerWarmingEnergyBase() - : artificialViscosity( 1.0 ){}; - static String getType() { return String( "StegerWarmingEnergy< " ) + @@ -71,15 +68,9 @@ class StegerWarmingEnergyBase { this->density = density; }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - }; void setDynamicalViscosity( const RealType& dynamicalViscosity ) { - this->dynamicalViscosity = dynamicalViscosity; this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); } @@ -94,8 +85,6 @@ class StegerWarmingEnergyBase OperatorRightHandSideType rightHandSide; MeshFunctionPointer pressure; - - RealType artificialViscosity, dynamicalViscosity; MeshFunctionPointer density; }; @@ -191,8 +180,6 @@ class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Opera const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); @@ -323,18 +310,11 @@ class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Opera const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -352,21 +332,13 @@ class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Opera const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) @@ -486,10 +458,6 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Opera const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); @@ -498,18 +466,6 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Opera const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -534,14 +490,6 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Opera const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; @@ -550,14 +498,6 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Opera const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; @@ -565,15 +505,7 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Opera const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h index 98e7b8b7f..712cd9ee4 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h @@ -62,7 +62,6 @@ class StegerWarmingMomentumBase void setDynamicalViscosity( const RealType& dynamicalViscosity ) { - this->dynamicalViscosity = dynamicalViscosity; this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); } @@ -134,8 +133,6 @@ class StegerWarmingMomentumBase MeshFunctionPointer pressure; - RealType dynamicalViscosity; - MeshFunctionPointer density; }; diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h index 4b729d5bd..c6588083c 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h @@ -69,8 +69,6 @@ class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Op const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); @@ -169,10 +167,6 @@ class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Op const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -191,18 +185,10 @@ class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Op const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) @@ -284,10 +270,6 @@ class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); @@ -296,18 +278,6 @@ class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -332,38 +302,14 @@ class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h index a71422df5..210fb6087 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h @@ -134,18 +134,11 @@ class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Op const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -161,21 +154,13 @@ class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Op const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) @@ -255,10 +240,6 @@ class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); @@ -267,18 +248,6 @@ class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -299,14 +268,6 @@ class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; @@ -315,26 +276,10 @@ class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h index 748e9b1b3..eab31d9f1 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h @@ -195,10 +195,6 @@ class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); @@ -207,18 +203,6 @@ class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; @@ -239,26 +223,10 @@ class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; @@ -266,15 +234,7 @@ class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; return -hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h index 1bf447399..97414370f 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h @@ -21,9 +21,12 @@ #include "VanLeerMomentumY.h" #include "VanLeerMomentumZ.h" +#include "Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h" + namespace TNL { template< typename Mesh, + typename OperatorRightHandSide = NullOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class VanLeer @@ -36,12 +39,18 @@ class VanLeer typedef Functions::MeshFunction< Mesh > MeshFunctionType; static const int Dimensions = Mesh::getMeshDimension(); typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; - typedef VanLeerContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef VanLeerMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef VanLeerMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef VanLeerMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef VanLeerEnergy< Mesh, Real, Index > EnergyOperatorType; + typedef VanLeerContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef VanLeerMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef VanLeerMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef VanLeerMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef VanLeerEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h index 2bcde13d2..3b497125a 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h @@ -20,6 +20,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class VanLeerContinuityBase @@ -36,6 +37,7 @@ class VanLeerContinuityBase typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; static String getType() { @@ -103,12 +105,15 @@ class VanLeerContinuityBase VelocityFieldPointer velocity; + OperatorRightHandSideType rightHandSide; + MeshFunctionPointer pressure; }; template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class VanLeerContinuity @@ -120,14 +125,15 @@ class VanLeerContinuity template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -167,7 +173,9 @@ class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, I - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ); + ) + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -191,14 +199,15 @@ class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, I template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -254,7 +263,9 @@ class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, I - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ); + ) + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -278,14 +289,15 @@ class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, I template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -356,7 +368,9 @@ class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, I - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) - ); + ) + + + this->rightHandSide(u, entity, time); } diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h index 2a23060cf..59cff3c66 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h @@ -16,6 +16,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class VanLeerEnergyBase @@ -32,6 +33,7 @@ class VanLeerEnergyBase typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; VanLeerEnergyBase() : artificialViscosity( 1.0 ){}; @@ -57,6 +59,7 @@ class VanLeerEnergyBase void setVelocity( const VelocityFieldPointer& velocity ) { this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); }; void setPressure( const MeshFunctionPointer& pressure ) @@ -77,6 +80,7 @@ class VanLeerEnergyBase void setDynamicalViscosity( const RealType& dynamicalViscosity ) { this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); } protected: @@ -86,6 +90,8 @@ class VanLeerEnergyBase RealType gamma; VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; MeshFunctionPointer pressure; @@ -95,6 +101,7 @@ class VanLeerEnergyBase }; template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class VanLeerEnergy @@ -104,15 +111,16 @@ class VanLeerEnergy template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -194,11 +202,8 @@ class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) ) -// 1D uT_11_x - - 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse / 4 - * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } @@ -223,14 +228,15 @@ class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -348,38 +354,8 @@ class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) ) -// 2D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - - velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 2D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_east - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -403,14 +379,15 @@ class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -580,87 +557,8 @@ class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) ) -// 3D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east - - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// wT_31_x - + ( ( velocity_z_upEast * velocity_z_east - velocity_z_downEast * velocity_z_east - - velocity_z_upWest * velocity_z_west + velocity_z_downWest * velocity_z_west - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east * velocity_z_center - velocity_x_center * velocity_z_west - - velocity_x_center * velocity_z_center + velocity_x_west * velocity_z_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - + velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// wT_32_y - + ( ( velocity_z_upNorth * velocity_z_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_z_south + velocity_z_downSouth * velocity_z_south - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north * velocity_z_center - velocity_y_center * velocity_z_south - - velocity_y_center * velocity_z_center + velocity_y_south * velocity_z_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// uT_13_z - + ( ( velocity_z_up * velocity_x_center - velocity_z_center * velocity_x_center - - velocity_z_center * velocity_x_down + velocity_z_down * velocity_x_down - ) * hzSquareInverse - + ( velocity_x_upEast * velocity_x_up - velocity_x_downEast * velocity_x_down - - velocity_x_upWest * velocity_x_up + velocity_x_downWest * velocity_x_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth * velocity_y_up - velocity_y_downNorth * velocity_y_down - - velocity_y_upSouth * velocity_y_up + velocity_y_downSouth * velocity_y_down - ) * hyInverse * hzInverse / 4 - + ( velocity_z_up * velocity_y_center - velocity_z_center * velocity_y_down - - velocity_z_center * velocity_y_center + velocity_z_down * velocity_y_down - ) * hzSquareInverse - ) * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down - - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down - ) * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down - - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down - ) * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down - - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h index d4ac78f3b..7ce89a972 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h @@ -14,6 +14,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class VanLeerMomentumBase @@ -30,6 +31,7 @@ class VanLeerMomentumBase typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; void setTau(const Real& tau) @@ -45,6 +47,7 @@ class VanLeerMomentumBase void setVelocity( const VelocityFieldPointer& velocity ) { this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); }; void setDensity( const MeshFunctionPointer& density ) @@ -60,6 +63,7 @@ class VanLeerMomentumBase void setDynamicalViscosity( const RealType& dynamicalViscosity ) { this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); } RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const @@ -117,6 +121,8 @@ class VanLeerMomentumBase RealType gamma; VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; MeshFunctionPointer pressure; diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h index 8b7673a09..04e41c015 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h @@ -18,6 +18,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class VanLeerMomentumX @@ -27,15 +28,16 @@ class VanLeerMomentumX template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -92,10 +94,8 @@ class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, In - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) ) -// 1D T_11_x - - 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -119,14 +119,15 @@ class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, In template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -215,18 +216,8 @@ class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) ) -// 2D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_21_y - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south - ) * hxInverse * hyInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } @@ -252,14 +243,15 @@ class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -391,26 +383,8 @@ class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) ) -// 3D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_21_x - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// T_31_x - + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h index 225903dd2..65ac84828 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h @@ -18,6 +18,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class VanLeerMomentumY @@ -27,15 +28,16 @@ class VanLeerMomentumY template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -90,14 +92,15 @@ class VanLeerMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, In template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -186,18 +189,8 @@ class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) ) -// 2D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_12_x - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east - ) * hxSquareInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > @@ -221,14 +214,15 @@ class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -360,26 +354,8 @@ class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) ) -// T_12_y - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_32_y - + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } /*template< typename MeshEntity > diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h index 3567f5815..125166cb8 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h @@ -18,6 +18,7 @@ namespace TNL { template< typename Mesh, + typename OperatorRightHandSide, typename Real = typename Mesh::RealType, typename Index = typename Mesh::IndexType > class VanLeerMomentumZ @@ -27,15 +28,16 @@ class VanLeerMomentumZ template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -90,14 +92,15 @@ class VanLeerMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, In template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -151,14 +154,15 @@ class VanLeerMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, In template< typename MeshReal, typename Device, typename MeshIndex, + typename OperatorRightHandSide, typename Real, typename Index > -class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > { public: typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; using typename BaseType::RealType; using typename BaseType::IndexType; @@ -290,29 +294,8 @@ class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Ind - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) ) -// T_13_z - + ( ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - + ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - ) - * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity; + + + this->rightHandSide(u, entity, time); } diff --git a/src/Examples/flows/RiemannProblemInitialCondition.h b/src/Examples/flows/RiemannProblemInitialCondition.h index 5414fcd6d..0c343589b 100644 --- a/src/Examples/flows/RiemannProblemInitialCondition.h +++ b/src/Examples/flows/RiemannProblemInitialCondition.h @@ -887,7 +887,7 @@ class RiemannProblemInitialCondition this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); - this->SWUEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); + this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); this->NWDMomentum = NWDVelocity * NWDDensity; this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); diff --git a/src/Examples/flows/flowsBuildConfigTag.h b/src/Examples/flows/flowsBuildConfigTag.h index 0039caada..c40b793b9 100644 --- a/src/Examples/flows/flowsBuildConfigTag.h +++ b/src/Examples/flows/flowsBuildConfigTag.h @@ -51,7 +51,7 @@ template<> struct ConfigTagExplicitSolver< flowsBuildConfigTag, ExplicitEulerSol namespace Meshes { namespace BuildConfigTags { -template< int Dimensions > struct GridDimensionTag< flowsBuildConfigTag, Dimensions >{ enum { enabled = ( Dimensions == 1 ) }; }; +template< int Dimensions > struct GridDimensionTag< flowsBuildConfigTag, Dimensions >{ enum { enabled = true }; }; /**** * Turn off support for float and long double. diff --git a/src/Examples/flows/navierStokes.h b/src/Examples/flows/navierStokes.h index 884bf11f4..3d0155851 100644 --- a/src/Examples/flows/navierStokes.h +++ b/src/Examples/flows/navierStokes.h @@ -14,6 +14,8 @@ #include "RiemannProblemInitialCondition.h" #include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" #include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" #include "DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h" #include "DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h" @@ -40,11 +42,13 @@ template< typename ConfigTag >class navierStokesConfig config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); config.addEntryEnum< String >( "boiler" ); config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); config.addEntry< String >( "differential-operator", "Choose the differential operator.", "Lax-Friedrichs"); config.addEntryEnum< String >( "Lax-Friedrichs" ); config.addEntryEnum< String >( "Steger-Warming" ); config.addEntryEnum< String >( "VanLeer" ); - config.addEntry< String >( "oprator-right-hand-side", "Choose equation type.", "Euler"); + config.addEntry< String >( "operator-right-hand-side", "Choose equation type.", "Euler"); config.addEntryEnum< String >( "Euler" ); config.addEntryEnum< String >( "Navier-Stokes" ); config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); @@ -95,7 +99,7 @@ class navierStokesSetter else if( differentialOperatorType == "Steger-Warming" ) typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; else if( differentialOperatorType == "VanLeer" ) - typedef VanLeer< MeshType, Real, Index > ApproximateOperator; + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; /**** * Resolve the template arguments of your solver here. @@ -107,6 +111,7 @@ class navierStokesSetter String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); if( boundaryConditionsType == "cavity" ) { + cout<<"cavity" << endl; typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; SolverStarter solverStarter; @@ -118,7 +123,22 @@ class navierStokesSetter typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; SolverStarter solverStarter; return solverStarter.template run< Problem >( parameters ); - } + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, MeshFunction, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, MeshFunction, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } return true;} diff --git a/src/Examples/flows/navierStokesProblem.h b/src/Examples/flows/navierStokesProblem.h index e195513fa..034a1c7af 100644 --- a/src/Examples/flows/navierStokesProblem.h +++ b/src/Examples/flows/navierStokesProblem.h @@ -84,6 +84,10 @@ class navierStokesProblem: const RealType& tau, DofVectorPointer& _u, DofVectorPointer& _fu ); + + void applyBoundaryConditions( const RealType& time, + DofVectorPointer& dofs ) { cout << "PBC" << endl; +cin.ignore();/*TNL_ASSERT( false, "TODO:Implement")*/}; template< typename Matrix > void assemblyLinearSystem( const RealType& time, diff --git a/src/Examples/flows/navierStokesProblem_impl.h b/src/Examples/flows/navierStokesProblem_impl.h index b43fe2ac0..550bb8fda 100644 --- a/src/Examples/flows/navierStokesProblem_impl.h +++ b/src/Examples/flows/navierStokesProblem_impl.h @@ -275,6 +275,7 @@ getExplicitUpdate( const RealType& time, this->boundaryConditionPointer->setGamma(this->gamma); this->boundaryConditionPointer->setPressure(this->pressure); + /**** * Continuity equation */ @@ -296,7 +297,6 @@ getExplicitUpdate( const RealType& time, explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); - if( Dimensions > 1 ) { Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumYOperatorType, MomentumYBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumY; @@ -307,7 +307,7 @@ getExplicitUpdate( const RealType& time, ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); } - + if( Dimensions > 2 ) { Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, MomentumZBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumZ; diff --git a/src/TNL/Solvers/PDE/ExplicitUpdater.h b/src/TNL/Solvers/PDE/ExplicitUpdater.h index 042c06714..84a2ef6fc 100644 --- a/src/TNL/Solvers/PDE/ExplicitUpdater.h +++ b/src/TNL/Solvers/PDE/ExplicitUpdater.h @@ -157,7 +157,7 @@ class ExplicitUpdater "The boundary conditions are not correctly set-up. Use method setBoundaryCondtions() to do it." ); TNL_ASSERT_TRUE( &uPointer.template modifyData< DeviceType >(), "The function u is not correctly set-up. It was not bound probably with DOFs." ); - + cout << "BC" << endl; this->userData.time = time; this->userData.u = &uPointer.template modifyData< DeviceType >(); Meshes::Traverser< MeshType, EntityType > meshTraverser; -- GitLab From 65c38d777414770d3480e67780495649af834900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Tue, 6 Nov 2018 07:53:38 +0100 Subject: [PATCH 06/28] Added dirichlet and neumann BC, resolved explicit updaters for BC --- .../Cavity/BoundaryConditionsCavity.h | 1 - .../Cavity/EnergyBoundaryConditionCavity.h | 1 - .../Dirichlet/BoundaryConditionsDirichlet.h | 112 ++++++++++ .../Neumann/BoundaryConditionsNeumann.h | 108 ++++++++++ src/Examples/flows/navierStokes.h | 5 +- src/Examples/flows/navierStokesProblem.h | 11 +- src/Examples/flows/navierStokesProblem_impl.h | 197 +++++++++++------- src/TNL/Solvers/PDE/ExplicitUpdater.h | 1 - 8 files changed, 356 insertions(+), 80 deletions(-) create mode 100644 src/Examples/flows/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h create mode 100644 src/Examples/flows/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h diff --git a/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h index a6e7424ca..bbae2d3e9 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h @@ -93,7 +93,6 @@ class BoundaryConditionsCavity void setSpeed(const RealType cavitySpeed) { - cout <<"setSpeed" << endl; this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); diff --git a/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h index a302ab147..6cdbd6a87 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h @@ -268,7 +268,6 @@ class EnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshInd const MeshType& mesh = entity.getMesh(); const auto& neighborEntities = entity.getNeighborEntities(); const IndexType& index = entity.getIndex(); - cout << "energy" << endl; if( entity.getCoordinates().x() == 0 ) { return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; diff --git a/src/Examples/flows/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h b/src/Examples/flows/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h new file mode 100644 index 000000000..095f9ef3f --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h @@ -0,0 +1,112 @@ +#include +#include +#include +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Function = Functions::Analytic::Constant< Mesh::getMeshDimension(), typename Mesh::RealType >, + int MeshEntitiesDimension = Mesh::getMeshDimension(), + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class BoundaryConditionsDirichlet +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > EnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + + } + + void setTimestep(const RealType timestep) + { + + } + + void setGamma(const RealType gamma) + { + + } + + void setPressure(const MeshFunctionPointer& pressure) + { + + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/flows/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h b/src/Examples/flows/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h new file mode 100644 index 000000000..5d44c091d --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h @@ -0,0 +1,108 @@ +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class BoundaryConditionsNeumann +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + + } + + void setTimestep(const RealType timestep) + { + + } + + void setGamma(const RealType gamma) + { + + } + + void setPressure(const MeshFunctionPointer& pressure) + { + + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/flows/navierStokes.h b/src/Examples/flows/navierStokes.h index 3d0155851..9ce79a054 100644 --- a/src/Examples/flows/navierStokes.h +++ b/src/Examples/flows/navierStokes.h @@ -111,7 +111,6 @@ class navierStokesSetter String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); if( boundaryConditionsType == "cavity" ) { - cout<<"cavity" << endl; typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; SolverStarter solverStarter; @@ -127,14 +126,14 @@ class navierStokesSetter typedef Functions::MeshFunction< MeshType > MeshFunction; if( boundaryConditionsType == "dirichlet" ) { - typedef BoundaryConditionsDirichlet< MeshType, MeshFunction, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; SolverStarter solverStarter; return solverStarter.template run< Problem >( parameters ); } if( boundaryConditionsType == "neumann" ) { - typedef BoundaryConditionsNeumann< MeshType, MeshFunction, Real, Index > BoundaryConditions; + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; SolverStarter solverStarter; return solverStarter.template run< Problem >( parameters ); diff --git a/src/Examples/flows/navierStokesProblem.h b/src/Examples/flows/navierStokesProblem.h index 034a1c7af..999431fb2 100644 --- a/src/Examples/flows/navierStokesProblem.h +++ b/src/Examples/flows/navierStokesProblem.h @@ -12,6 +12,7 @@ #include #include +#include #include "CompressibleConservativeVariables.h" @@ -86,8 +87,7 @@ class navierStokesProblem: DofVectorPointer& _fu ); void applyBoundaryConditions( const RealType& time, - DofVectorPointer& dofs ) { cout << "PBC" << endl; -cin.ignore();/*TNL_ASSERT( false, "TODO:Implement")*/}; + DofVectorPointer& dofs ); template< typename Matrix > void assemblyLinearSystem( const RealType& time, @@ -109,6 +109,13 @@ cin.ignore();/*TNL_ASSERT( false, "TODO:Implement")*/}; ConservativeVariablesPointer conservativeVariables, conservativeVariablesRHS; + + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::ContinuityOperatorType, typename BoundaryCondition::DensityBoundaryConditionsType, RightHandSide > explicitUpdaterContinuity; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumXOperatorType, typename BoundaryCondition::MomentumXBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumX; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumYOperatorType, typename BoundaryCondition::MomentumYBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumY; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumZOperatorType, typename BoundaryCondition::MomentumZBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumZ; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::EnergyOperatorType, typename BoundaryCondition::EnergyBoundaryConditionsType, RightHandSide > explicitUpdaterEnergy; + VelocityFieldPointer velocity; MeshFunctionPointer pressure; diff --git a/src/Examples/flows/navierStokesProblem_impl.h b/src/Examples/flows/navierStokesProblem_impl.h index 550bb8fda..a27de41a0 100644 --- a/src/Examples/flows/navierStokesProblem_impl.h +++ b/src/Examples/flows/navierStokesProblem_impl.h @@ -80,6 +80,51 @@ setup( const Config::ParameterContainer& parameters, this->gamma = parameters.getParameter< double >( "gamma" ); velocity->setMesh( this->getMesh() ); pressure->setMesh( this->getMesh() ); + + /**** + * Set-up operators + */ + + this->inviscidOperatorsPointer->setVelocity( this->velocity ); + this->inviscidOperatorsPointer->setPressure( this->pressure ); + this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); + this->inviscidOperatorsPointer->setGamma( this->gamma ); + + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); + this->explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer->getDensityBoundaryCondition() ); + this->explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); + + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); + this->explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer->getMomentumXBoundaryCondition() ); + this->explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); + + if( Dimensions > 1 ) + { + this->explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); + this->explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer->getMomentumYBoundaryCondition() ); + this->explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); + this->explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer->getMomentumZBoundaryCondition() ); + this->explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); + this->explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer->getEnergyBoundaryCondition() ); + this->explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); + return true; } @@ -201,7 +246,6 @@ makeSnapshot( const RealType& time, fileName.setFileNameBase( "energy-" ); if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) return false; - return true; } @@ -224,8 +268,6 @@ getExplicitUpdate( const RealType& time, */ this->conservativeVariables->bind( this->getMesh(), _u ); this->conservativeVariablesRHS->bind( this->getMesh(), _fu ); - this->velocity->setMesh( this->getMesh() ); - this->pressure->setMesh( this->getMesh() ); /**** * Resolve the physical variables @@ -233,101 +275,47 @@ getExplicitUpdate( const RealType& time, PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - + /**** * Set-up operators */ - typedef typename InviscidOperators::ContinuityOperatorType ContinuityOperatorType; - typedef typename InviscidOperators::MomentumXOperatorType MomentumXOperatorType; - typedef typename InviscidOperators::MomentumYOperatorType MomentumYOperatorType; - typedef typename InviscidOperators::MomentumZOperatorType MomentumZOperatorType; - typedef typename InviscidOperators::EnergyOperatorType EnergyOperatorType; + + this->inviscidOperatorsPointer->setTau( tau ); - this->inviscidOperatorsPointer->setTau( tau ); - this->inviscidOperatorsPointer->setVelocity( this->velocity ); - this->inviscidOperatorsPointer->setPressure( this->pressure ); - this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); - this->inviscidOperatorsPointer->setGamma( this->gamma ); - - /**** - * Set Up Boundary Conditions - */ - - typedef typename BoundaryCondition::DensityBoundaryConditionsType DensityBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumXBoundaryConditionsType MomentumXBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumYBoundaryConditionsType MomentumYBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumZBoundaryConditionsType MomentumZBoundaryConditionsType; - typedef typename BoundaryCondition::EnergyBoundaryConditionsType EnergyBoundaryConditionsType; - - /**** - * Update Boundary Conditions - */ - if(this->speedIncrementUntil > time ) - { - this->boundaryConditionPointer->setTimestep(this->speedIncrement); - } - else - { - this->boundaryConditionPointer->setTimestep(0); - } - this->boundaryConditionPointer->setSpeed(this->cavitySpeed); - this->boundaryConditionPointer->setCompressibleConservativeVariables(this->conservativeVariables); - this->boundaryConditionPointer->setGamma(this->gamma); - this->boundaryConditionPointer->setPressure(this->pressure); - - /**** * Continuity equation */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, ContinuityOperatorType, DensityBoundaryConditionsType, RightHandSide > explicitUpdaterContinuity; - explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); - explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer->getDensityBoundaryCondition() ); - explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), this->conservativeVariables->getDensity(), this->conservativeVariablesRHS->getDensity() ); +// this->explicitUpdaterContinuity.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, +// this->conservativeVariables->getDensity() ); + /**** * Momentum equations - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumXOperatorType, MomentumXBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumX; - explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); - explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer->getMomentumXBoundaryCondition() ); - explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + */ + this->explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); if( Dimensions > 1 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumYOperatorType, MomentumYBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumY; - explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); - explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer->getMomentumYBoundaryCondition() ); - explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + { + this->explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); } if( Dimensions > 2 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, MomentumZBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumZ; - explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); - explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer->getMomentumZBoundaryCondition() ); - explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + { + this->explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); } - /**** * Energy equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, EnergyOperatorType, EnergyBoundaryConditionsType, RightHandSide > explicitUpdaterEnergy; - explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); - explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer->getEnergyBoundaryCondition() ); - explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + */ + this->explicitUpdaterEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), this->conservativeVariables->getEnergy(), // uRhoVelocityX, this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); @@ -338,6 +326,71 @@ getExplicitUpdate( const RealType& time, } +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +applyBoundaryConditions( const RealType& time, + DofVectorPointer& dofs ) +{ + /**** + * Update Boundary Conditions + */ + if(this->speedIncrementUntil > time ) + { + this->boundaryConditionPointer->setTimestep(this->speedIncrement); + } + else + { + this->boundaryConditionPointer->setTimestep(0); + } + this->boundaryConditionPointer->setSpeed(this->cavitySpeed); + this->boundaryConditionPointer->setCompressibleConservativeVariables(this->conservativeVariables); + this->boundaryConditionPointer->setGamma(this->gamma); + this->boundaryConditionPointer->setPressure(this->pressure); + /**** + * Bind DOFs + */ + this->conservativeVariables->bind( this->getMesh(), dofs ); +// this->conservativeVariables->getDensity()->write( "density", "gnuplot" ); +// this->conservativeVariables->getEnergy()->write( "energy", "gnuplot" ); +// this->conservativeVariables->getMomentum()->write( "momentum", "gnuplot", 0.05 ); +// dofs->save("dofs.tnl"); +// getchar(); +// std::cout <<"applyBCC" << std::endl; + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getDensity() ); + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 0 ] ); // uRhoVelocityX, + if( Dimensions > 1 ) + { + + this->explicitUpdaterMomentumY.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 1 ] ); // uRhoVelocityX, + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 2 ] ); // uRhoVelocityX, + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getEnergy() ); // uRhoVelocityX, +} + template< typename Mesh, typename BoundaryCondition, typename RightHandSide, diff --git a/src/TNL/Solvers/PDE/ExplicitUpdater.h b/src/TNL/Solvers/PDE/ExplicitUpdater.h index 84a2ef6fc..9644aa916 100644 --- a/src/TNL/Solvers/PDE/ExplicitUpdater.h +++ b/src/TNL/Solvers/PDE/ExplicitUpdater.h @@ -157,7 +157,6 @@ class ExplicitUpdater "The boundary conditions are not correctly set-up. Use method setBoundaryCondtions() to do it." ); TNL_ASSERT_TRUE( &uPointer.template modifyData< DeviceType >(), "The function u is not correctly set-up. It was not bound probably with DOFs." ); - cout << "BC" << endl; this->userData.time = time; this->userData.u = &uPointer.template modifyData< DeviceType >(); Meshes::Traverser< MeshType, EntityType > meshTraverser; -- GitLab From 56cfd64cede3bc3fe5ed0fcb3eb11a22d32dd6a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Wed, 7 Nov 2018 20:49:00 +0100 Subject: [PATCH 07/28] removed unused files --- .../advection/Riemann1DBoundaryConditions.h | 150 -- .../advection/Riemann2DBoundaryConditions.h | 153 -- src/Examples/advection/tnl-run-advection | 28 - src/Examples/flow-sw/CMakeLists.txt | 22 - src/Examples/flow-sw/UpwindEnergy.h | 719 --------- src/Examples/flow-sw/UpwindMomentumBase.h | 141 -- src/Examples/flow-sw/navierStokesProblem.h | 127 -- .../flow-vl/DensityBoundaryConditionCavity.h | 536 ------- .../flow-vl/EnergyBoundaryConditionCavity.h | 673 -------- .../flow-vl/RiemannProblemInitialCondition.h | 1417 ----------------- src/Examples/flow-vl/Upwind.h | 158 -- src/Examples/flow-vl/UpwindMomentumX.h | 433 ----- src/Examples/flow-vl/UpwindMomentumY.h | 403 ----- src/Examples/flow-vl/UpwindMomentumZ.h | 338 ---- src/Examples/flow-vl/navierStokes.h | 107 -- .../flow-vl/navierStokesProblem_impl.h | 458 ------ src/Examples/flow/BoundaryConditionsBoiler.h | 137 -- src/Examples/flow/BoundaryConditionsCavity.h | 137 -- .../flow/DensityBoundaryConditionBoiler.h | 542 ------- .../flow/EnergyBoundaryConditionBoiler.h | 854 ---------- .../flow/MomentumXBoundaryConditionBoiler.h | 594 ------- .../flow/MomentumXBoundaryConditionCavity.h | 570 ------- .../flow/MomentumYBoundaryConditionBoiler.h | 588 ------- .../flow/MomentumYBoundaryConditionCavity.h | 564 ------- .../flow/MomentumZBoundaryConditionBoiler.h | 563 ------- .../flow/MomentumZBoundaryConditionCavity.h | 554 ------- src/Examples/flow/navierStokes.cpp | 1 - src/Examples/flow/navierStokes.cu | 1 - .../flow/navierStokesBuildConfigTag.h | 60 - src/Examples/flow/navierStokesRhs.h | 35 - src/Examples/flows/CMakeLists.txt | 26 - .../Euler/Lax-Friedrichs/LaxFridrichs.h | 149 -- .../Lax-Friedrichs/LaxFridrichsContinuity.h | 297 ---- .../Euler/Lax-Friedrichs/LaxFridrichsEnergy.h | 320 ---- .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 68 - .../Lax-Friedrichs/LaxFridrichsMomentumX.h | 286 ---- .../Lax-Friedrichs/LaxFridrichsMomentumY.h | 268 ---- .../Lax-Friedrichs/LaxFridrichsMomentumZ.h | 245 --- .../Euler/Steger-Warming/StegerWarming.h | 151 -- .../Steger-Warming/StegerWarmingContinuity.h | 381 ----- .../Steger-Warming/StegerWarmingEnergy.h | 540 ------- .../StegerWarmingMomentumBase.h | 130 -- .../Steger-Warming/StegerWarmingMomentumX.h | 343 ---- .../Steger-Warming/StegerWarmingMomentumY.h | 318 ---- .../Steger-Warming/StegerWarmingMomentumZ.h | 276 ---- .../Euler/VanLeer/VanLeer.h | 151 -- .../Euler/VanLeer/VanLeerContinuity.h | 382 ----- .../Euler/VanLeer/VanLeerEnergy.h | 504 ------ .../Euler/VanLeer/VanLeerMomentumBase.h | 122 -- .../Euler/VanLeer/VanLeerMomentumX.h | 343 ---- .../Euler/VanLeer/VanLeerMomentumY.h | 318 ---- .../Euler/VanLeer/VanLeerMomentumZ.h | 276 ---- src/Examples/flows/euler.cpp | 1 - src/Examples/flows/euler.cu | 1 - src/Examples/flows/euler.h | 134 -- src/Examples/flows/eulerProblem.h | 119 -- src/Examples/flows/eulerProblem_impl.h | 416 ----- src/Examples/flows/run-euler | 25 - src/Examples/flows/run-navier-stokes | 41 +- .../inviscid-flow-sw/UpwindContinuity.h | 382 ----- .../CompressibleConservativeVariables.h | 147 -- .../PhysicalVariablesGetter.h | 122 -- .../CompressibleConservativeVariables.h | 147 -- src/Examples/inviscid-flow/LaxFridrichs.h | 141 -- .../inviscid-flow/LaxFridrichsContinuity.h | 288 ---- .../inviscid-flow/LaxFridrichsEnergy.h | 309 ---- .../inviscid-flow/LaxFridrichsMomentumBase.h | 68 - .../inviscid-flow/LaxFridrichsMomentumX.h | 276 ---- .../inviscid-flow/LaxFridrichsMomentumY.h | 260 --- .../inviscid-flow/LaxFridrichsMomentumZ.h | 240 --- .../inviscid-flow/PhysicalVariablesGetter.h | 122 -- src/Examples/inviscid-flow/run-euler | 25 - 72 files changed, 28 insertions(+), 20193 deletions(-) delete mode 100644 src/Examples/advection/Riemann1DBoundaryConditions.h delete mode 100644 src/Examples/advection/Riemann2DBoundaryConditions.h delete mode 100644 src/Examples/advection/tnl-run-advection delete mode 100644 src/Examples/flow-sw/CMakeLists.txt delete mode 100644 src/Examples/flow-sw/UpwindEnergy.h delete mode 100644 src/Examples/flow-sw/UpwindMomentumBase.h delete mode 100644 src/Examples/flow-sw/navierStokesProblem.h delete mode 100644 src/Examples/flow-vl/DensityBoundaryConditionCavity.h delete mode 100644 src/Examples/flow-vl/EnergyBoundaryConditionCavity.h delete mode 100644 src/Examples/flow-vl/RiemannProblemInitialCondition.h delete mode 100644 src/Examples/flow-vl/Upwind.h delete mode 100644 src/Examples/flow-vl/UpwindMomentumX.h delete mode 100644 src/Examples/flow-vl/UpwindMomentumY.h delete mode 100644 src/Examples/flow-vl/UpwindMomentumZ.h delete mode 100644 src/Examples/flow-vl/navierStokes.h delete mode 100644 src/Examples/flow-vl/navierStokesProblem_impl.h delete mode 100644 src/Examples/flow/BoundaryConditionsBoiler.h delete mode 100644 src/Examples/flow/BoundaryConditionsCavity.h delete mode 100644 src/Examples/flow/DensityBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow/EnergyBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow/MomentumXBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow/MomentumXBoundaryConditionCavity.h delete mode 100644 src/Examples/flow/MomentumYBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow/MomentumYBoundaryConditionCavity.h delete mode 100644 src/Examples/flow/MomentumZBoundaryConditionBoiler.h delete mode 100644 src/Examples/flow/MomentumZBoundaryConditionCavity.h delete mode 100644 src/Examples/flow/navierStokes.cpp delete mode 100644 src/Examples/flow/navierStokes.cu delete mode 100644 src/Examples/flow/navierStokesBuildConfigTag.h delete mode 100644 src/Examples/flow/navierStokesRhs.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h delete mode 100644 src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h delete mode 100644 src/Examples/flows/euler.cpp delete mode 100644 src/Examples/flows/euler.cu delete mode 100644 src/Examples/flows/euler.h delete mode 100644 src/Examples/flows/eulerProblem.h delete mode 100644 src/Examples/flows/eulerProblem_impl.h delete mode 100644 src/Examples/flows/run-euler delete mode 100644 src/Examples/inviscid-flow-sw/UpwindContinuity.h delete mode 100644 src/Examples/inviscid-flow-vl/CompressibleConservativeVariables.h delete mode 100644 src/Examples/inviscid-flow-vl/PhysicalVariablesGetter.h delete mode 100644 src/Examples/inviscid-flow/CompressibleConservativeVariables.h delete mode 100644 src/Examples/inviscid-flow/LaxFridrichs.h delete mode 100644 src/Examples/inviscid-flow/LaxFridrichsContinuity.h delete mode 100644 src/Examples/inviscid-flow/LaxFridrichsEnergy.h delete mode 100644 src/Examples/inviscid-flow/LaxFridrichsMomentumBase.h delete mode 100644 src/Examples/inviscid-flow/LaxFridrichsMomentumX.h delete mode 100644 src/Examples/inviscid-flow/LaxFridrichsMomentumY.h delete mode 100644 src/Examples/inviscid-flow/LaxFridrichsMomentumZ.h delete mode 100644 src/Examples/inviscid-flow/PhysicalVariablesGetter.h delete mode 100644 src/Examples/inviscid-flow/run-euler diff --git a/src/Examples/advection/Riemann1DBoundaryConditions.h b/src/Examples/advection/Riemann1DBoundaryConditions.h deleted file mode 100644 index 69ea8ebe8..000000000 --- a/src/Examples/advection/Riemann1DBoundaryConditions.h +++ /dev/null @@ -1,150 +0,0 @@ -//** coppied and changed -/*************************************************************************** - tnlRiemann1DBoundaryConditions.h - description - ------------------- - begin : Nov 17, 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 TNLRIEMANN1DBOUNDARYCONDITIONS_H_ -#define TNLRIEMANN1DBOUNDARYCONDITIONS_H_ - -#pragma once - -#include -#include -#include -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function = Functions::Analytic::Constant< Mesh::getMeshDimensions(), typename Mesh::RealType >, - int MeshEntitiesDimensions = Mesh::getMeshDimensions(), - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class Riemann1DBoundaryConditions -: public Operator< Mesh, - Functions::MeshBoundaryDomain, - MeshEntitiesDimensions, - MeshEntitiesDimensions, - Real, - Index > -{ - public: - - typedef Mesh MeshType; - typedef Function FunctionType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - - typedef Pointers::SharedPointer< Mesh > MeshPointer; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef typename MeshType::VertexType VertexType; - - static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< MeshType, FunctionType >::template setup< MeshPointer >( this->function, meshPointer, parameters, prefix ); - } - - void setFunction( const Function& function ) - { - this->function = function; - } - - Function& getFunction() - { - return this->function; - } - - const Function& getFunction() const - { - return this->function; - } - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighbourEntities = entity.getNeighbourEntities(); - if( entity.getCoordinates().x() == 0 ) - return 1.0; - else - return 0.0; - //tady se asi delaji okrajove podminky - //static_assert( EntityType::getDimensions() == MeshEntitiesDimensions, "Wrong mesh entity dimensions." ); - } - - template< typename EntityType > - __cuda_callable__ - IndexType getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 1; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - typename Matrix::MatrixRow matrixRow = matrix.getRow( entity.getIndex() ); - const IndexType& index = entity.getIndex(); - matrixRow.setElement( 0, index, 1.0 ); - b[ index ] = Functions::FunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); - } - - - protected: - - Function function; - - //static_assert( Device::DeviceType == Function::Device::DeviceType ); -}; - - -template< typename Mesh, - typename Function > -std::ostream& operator << ( std::ostream& str, const Riemann1DBoundaryConditions< Mesh, Function >& bc ) -{ - str << "Riemann1D boundary conditions: vector = " << bc.getVector(); - return str; -} - -} // namespace Operators -} // namespace TNL -#endif /* TNLRIEMANN1DBOUNDARYCONDITIONS_H_ */ diff --git a/src/Examples/advection/Riemann2DBoundaryConditions.h b/src/Examples/advection/Riemann2DBoundaryConditions.h deleted file mode 100644 index 33cafb773..000000000 --- a/src/Examples/advection/Riemann2DBoundaryConditions.h +++ /dev/null @@ -1,153 +0,0 @@ -//** coppied and changed -/*************************************************************************** - tnlRiemann2DBoundaryConditions.h - description - ------------------- - begin : Nov 17, 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 TNLRIEMANN2DBOUNDARYCONDITIONS_H_ -#define TNLRIEMANN2DBOUNDARYCONDITIONS_H_ - -#pragma once - -#include -#include -#include -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function = Functions::Analytic::Constant< Mesh::getMeshDimensions(), typename Mesh::RealType >, - int MeshEntitiesDimensions = Mesh::getMeshDimensions(), - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class Riemann2DBoundaryConditions -: public Operator< Mesh, - Functions::MeshBoundaryDomain, - MeshEntitiesDimensions, - MeshEntitiesDimensions, - Real, - Index > -{ - public: - - typedef Mesh MeshType; - typedef Function FunctionType; - typedef Real RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef Index IndexType; - - typedef Pointers::SharedPointer< Mesh > MeshPointer; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef typename MeshType::VertexType VertexType; - - static constexpr int getMeshDimensions() { return MeshType::meshDimensions; } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< MeshType, FunctionType >::template setup< MeshPointer >( this->function, meshPointer, parameters, prefix ); - } - - void setFunction( const Function& function ) - { - this->function = function; - } - - Function& getFunction() - { - return this->function; - } - - const Function& getFunction() const - { - return this->function; - } - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighbourEntities = entity.getNeighbourEntities(); - typedef typename MeshType::Cell Cell; - int count = mesh.template getEntitiesCount< Cell >(); - count = std::sqrt(count); - if( entity.getCoordinates().x() < count * 0.5 ) - return 1; - else - return 0; - //tady se asi delaji okrajove podminky - //static_assert( EntityType::getDimensions() == MeshEntitiesDimensions, "Wrong mesh entity dimensions." ); - } - - template< typename EntityType > - __cuda_callable__ - IndexType getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 1; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - typename Matrix::MatrixRow matrixRow = matrix.getRow( entity.getIndex() ); - const IndexType& index = entity.getIndex(); - matrixRow.setElement( 0, index, 1.0 ); - b[ index ] = Functions::FunctionAdapter< MeshType, Function >::getValue( this->function, entity, time ); - } - - - protected: - - Function function; - - //static_assert( Device::DeviceType == Function::Device::DeviceType ); -}; - - -template< typename Mesh, - typename Function > -std::ostream& operator << ( std::ostream& str, const Riemann2DBoundaryConditions< Mesh, Function >& bc ) -{ - str << "Riemann2D boundary conditions: vector = " << bc.getVector(); - return str; -} - -} // namespace Operators -} // namespace TNL -#endif /* RIEMANN2DBOUNDARYCONDITIONS_H_ */ diff --git a/src/Examples/advection/tnl-run-advection b/src/Examples/advection/tnl-run-advection deleted file mode 100644 index 28686f1d0..000000000 --- a/src/Examples/advection/tnl-run-advection +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 1 \ - --origin-x 0.0 \ - --proportions-x 1.0 \ - --size-x 50 \ - -#tnl-init --test-function sin-wave \ -# --output-file init.tnl -~/bak/tnl/Debug/bin/tnl-advection-dbg --time-discretisation explicit \ - --time-step 2.0e-2 \ - --boundary-conditions-constant 0 \ - --discrete-solver euler \ - --snapshot-period 1.0\ - --final-time 2.0 \ - --artifical-viscosity 0.5 \ - --begin exp \ - --move advection \ - --advection-speedX 0.2 \ - --dimension 1 \ - --realSize 1.0 - -tnl-view --mesh mesh.tnl --input-files *tnl - -tnl-diff --mesh mesh.tnl \ - --input-files a-*.tnl u-*.tnl \ - --mode halves \ - diff --git a/src/Examples/flow-sw/CMakeLists.txt b/src/Examples/flow-sw/CMakeLists.txt deleted file mode 100644 index cd53d411c..000000000 --- a/src/Examples/flow-sw/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -set( tnl_flow_sw_HEADERS - CompressibleConservativeVariables.h ) - -set( tnl_flow_sw_SOURCES - navierStokes.cpp - navierStokes.cu ) - -IF( BUILD_CUDA ) - CUDA_ADD_EXECUTABLE(tnl-navier-stokes-sw navierStokes.cu) - target_link_libraries (tnl-navier-stokes-sw ${CUSPARSE_LIBRARY} ) -ELSE( BUILD_CUDA ) - ADD_EXECUTABLE(tnl-navier-stokes-sw navierStokes.cpp) -ENDIF( BUILD_CUDA ) - - -INSTALL( TARGETS tnl-navier-stokes-sw - RUNTIME DESTINATION bin - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) - -INSTALL( FILES run-navier-stokes-sw - ${tnl_inviscid_flow_SOURCES} - DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/navier-stokes-sw ) diff --git a/src/Examples/flow-sw/UpwindEnergy.h b/src/Examples/flow-sw/UpwindEnergy.h deleted file mode 100644 index 6c7e94ec8..000000000 --- a/src/Examples/flow-sw/UpwindEnergy.h +++ /dev/null @@ -1,719 +0,0 @@ -/*************************************************************************** - UpwindEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - UpwindEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "UpwindEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - }; - - void setDynamicalViscosity( const RealType& dynamicalViscosity ) - { - this->dynamicalViscosity = dynamicalViscosity; - } - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity, dynamicalViscosity; - - MeshFunctionPointer density; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - __cuda_callable__ - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - }; - - __cuda_callable__ - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) - ) -// 1D uT_11_x - - 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse / 4 - * this->dynamicalViscosity; - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) - ) -// 2D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - - velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 2D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_east - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) - ) -// 3D uT_11_x - + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west - - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east - - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east - - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// wT_31_x - + ( ( velocity_z_upEast * velocity_z_east - velocity_z_downEast * velocity_z_east - - velocity_z_upWest * velocity_z_west + velocity_z_downWest * velocity_z_west - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east * velocity_z_center - velocity_x_center * velocity_z_west - - velocity_x_center * velocity_z_center + velocity_x_west * velocity_z_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - + velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D vT_22_y - + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// wT_32_y - + ( ( velocity_z_upNorth * velocity_z_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_z_south + velocity_z_downSouth * velocity_z_south - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north * velocity_z_center - velocity_y_center * velocity_z_south - - velocity_y_center * velocity_z_center + velocity_y_south * velocity_z_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// uT_13_z - + ( ( velocity_z_up * velocity_x_center - velocity_z_center * velocity_x_center - - velocity_z_center * velocity_x_down + velocity_z_down * velocity_x_down - ) * hzSquareInverse - + ( velocity_x_upEast * velocity_x_up - velocity_x_downEast * velocity_x_down - - velocity_x_upWest * velocity_x_up + velocity_x_downWest * velocity_x_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth * velocity_y_up - velocity_y_downNorth * velocity_y_down - - velocity_y_upSouth * velocity_y_up + velocity_y_downSouth * velocity_y_down - ) * hyInverse * hzInverse / 4 - + ( velocity_z_up * velocity_y_center - velocity_z_center * velocity_y_down - - velocity_z_center * velocity_y_center + velocity_z_down * velocity_y_down - ) * hzSquareInverse - ) * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down - - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down - ) * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down - - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down - ) * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down - - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/flow-sw/UpwindMomentumBase.h b/src/Examples/flow-sw/UpwindMomentumBase.h deleted file mode 100644 index 8761467af..000000000 --- a/src/Examples/flow-sw/UpwindMomentumBase.h +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - UpwindMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setDynamicalViscosity( const RealType& dynamicalViscosity ) - { - this->dynamicalViscosity = dynamicalViscosity; - } - - __cuda_callable__ - RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber + 1.0 ) * ( machNumber + 1.0 ) ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber + 1.0 ) * (machNumber + 1.0 ) ); - else - return density * velocity * velocity + pressure; - }; - - __cuda_callable__ - RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity * velocity + pressure; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber - 1.0 ) * (machNumber - 1.0 ) ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber - 1.0 ) * ( machNumber - 1.0 ) ); - else - return 0; - }; - - __cuda_callable__ - RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * velocity_other; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * velocity_other; - else - return density * velocity_main * velocity_other; - }; - - __cuda_callable__ - RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity_main * velocity_other; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * velocity_other; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * velocity_other; - else - return 0.0; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType dynamicalViscosity; - - MeshFunctionPointer density; - -}; - -} //namespace TNL diff --git a/src/Examples/flow-sw/navierStokesProblem.h b/src/Examples/flow-sw/navierStokesProblem.h deleted file mode 100644 index 0252a5c46..000000000 --- a/src/Examples/flow-sw/navierStokesProblem.h +++ /dev/null @@ -1,127 +0,0 @@ -/*************************************************************************** - navierStokesProblem.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include "CompressibleConservativeVariables.h" - - -using namespace TNL::Problems; - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -class navierStokesProblem: - public PDEProblem< Mesh, - Communicator, - typename InviscidOperators::RealType, - typename Mesh::DeviceType, - typename InviscidOperators::IndexType > -{ - public: - - typedef typename InviscidOperators::RealType RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef typename InviscidOperators::IndexType IndexType; - typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; - - using typename BaseType::MeshType; - using typename BaseType::MeshPointer; - using typename BaseType::DofVectorType; - using typename BaseType::DofVectorPointer; - static const int Dimensions = Mesh::getMeshDimension(); - - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; - typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; - typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; - using CommunicatorType = Communicator; - - static String getTypeStatic(); - - String getPrologHeader() const; - - void writeProlog( Logger& logger, - const Config::ParameterContainer& parameters ) const; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ); - - bool setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ); - - template< typename Matrix > - bool setupLinearSystem( Matrix& matrix ); - - bool makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ); - - IndexType getDofs() const; - - void bindDofs( DofVectorPointer& dofs ); - - void getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ); - - void applyBoundaryConditions( const RealType& time, - DofVectorPointer& dofs ) - { - throw Exceptions::NotImplementedError("TODO:Implement"); - } - - template< typename Matrix > - void assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs, - Matrix& matrix, - DofVectorPointer& rightHandSide ); - - bool postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ); - - protected: - - InviscidOperatorsPointer inviscidOperatorsPointer; - - BoundaryConditionPointer boundaryConditionPointer; - RightHandSidePointer rightHandSidePointer; - - ConservativeVariablesPointer conservativeVariables, - conservativeVariablesRHS; - - VelocityFieldPointer velocity; - MeshFunctionPointer pressure; - - RealType gamma; - RealType speedIncrement; - RealType cavitySpeed; - RealType speedIncrementUntil; -}; - -} // namespace TNL - -#include "navierStokesProblem_impl.h" - diff --git a/src/Examples/flow-vl/DensityBoundaryConditionCavity.h b/src/Examples/flow-vl/DensityBoundaryConditionCavity.h deleted file mode 100644 index 18eaff110..000000000 --- a/src/Examples/flow-vl/DensityBoundaryConditionCavity.h +++ /dev/null @@ -1,536 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class DensityBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class DensityBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return u[ neighborEntities.template getEntityIndex< 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-vl/EnergyBoundaryConditionCavity.h b/src/Examples/flow-vl/EnergyBoundaryConditionCavity.h deleted file mode 100644 index 3b49cd56e..000000000 --- a/src/Examples/flow-vl/EnergyBoundaryConditionCavity.h +++ /dev/null @@ -1,673 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class EnergyBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function> -class EnergyBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /* ( (* this->pressure)[ neighborEntities.template getEntityIndex< 1, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - * - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - )*/; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /* ( (* this->pressure)[ neighborEntities.template getEntityIndex< -1, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - )*/; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /* ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 1 >() ] - / ( this->gamma - 1 ) - ) - + 0 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - )*/; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, -1 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - * ( - this->cavitySpeed/* - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 )*/ - * - this->cavitySpeed/* - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 )*/ - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - ); - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - ( this->cavitySpeed - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 ) - ) - * - ( this->cavitySpeed - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 ) - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow-vl/RiemannProblemInitialCondition.h b/src/Examples/flow-vl/RiemannProblemInitialCondition.h deleted file mode 100644 index dfde32625..000000000 --- a/src/Examples/flow-vl/RiemannProblemInitialCondition.h +++ /dev/null @@ -1,1417 +0,0 @@ -/*************************************************************************** - RiemannProblemInitialCondition.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -template -class RiemannProblemInitialConditionSetter -{ - -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 1,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - { - CellType cell(mesh, CoordinatesType(i)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 2,MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) - { - CellType cell(mesh, CoordinatesType(i,j)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template -class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex > > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - - void setDiscontinuity(PointType discontinuityPlacement) - { - this->discontinuityPlacement = discontinuityPlacement; - }; - void setDensity(RealType NWUDensity, - RealType NEUDensity, - RealType SWUDensity, - RealType SEUDensity, - RealType NWDDensity, - RealType NEDDensity, - RealType SWDDensity, - RealType SEDDensity) - { - this->NWUDensity = NWUDensity; - this->NEUDensity = NEUDensity; - this->SWUDensity = SWUDensity; - this->SEUDensity = SEUDensity; - this->NWDDensity = NWDDensity; - this->NEDDensity = NEDDensity; - this->SWDDensity = SWDDensity; - this->SEDDensity = SEDDensity; - }; - - void setMomentum(PointType NWUMomentum, - PointType NEUMomentum, - PointType SWUMomentum, - PointType SEUMomentum, - PointType NWDMomentum, - PointType NEDMomentum, - PointType SWDMomentum, - PointType SEDMomentum) - { - this->NWUMomentum = NWUMomentum; - this->NEUMomentum = NEUMomentum; - this->SWUMomentum = SWUMomentum; - this->SEUMomentum = SEUMomentum; - this->NWDMomentum = NWDMomentum; - this->NEDMomentum = NEDMomentum; - this->SWDMomentum = SWDMomentum; - this->SEDMomentum = SEDMomentum; - }; - - void setEnergy(RealType NWUEnergy, - RealType NEUEnergy, - RealType SWUEnergy, - RealType SEUEnergy, - RealType NWDEnergy, - RealType NEDEnergy, - RealType SWDEnergy, - RealType SEDEnergy) - { - this->NWUEnergy = NWUEnergy; - this->NEUEnergy = NEUEnergy; - this->SWUEnergy = SWUEnergy; - this->SEUEnergy = SEUEnergy; - this->NWDEnergy = NWDEnergy; - this->NEDEnergy = NEDEnergy; - this->SWDEnergy = SWDEnergy; - this->SEDEnergy = SEDEnergy; - }; - - void setGamma(RealType gamma) - { - this->gamma = gamma; - }; - - void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); - } - }; - - void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NWDMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NEDMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); - (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); - (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); - } - }; - - void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) - { - typedef typename MeshType::Cell CellType; - typedef typename MeshType::CoordinatesType CoordinatesType; - MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); - for( int i = 0; i < mesh.getDimensions().x(); i++) - for( int j = 0; j < mesh.getDimensions().y(); j++) - for ( int k = 0; k < mesh.getDimensions().z(); k++) - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - else - if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); - } - else - if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) - && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) - && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) - { - CellType cell(mesh, CoordinatesType(i,j,k)); - cell.refresh(); - (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); - } - }; - - PointType discontinuityPlacement; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType gamma; -}; - -template< typename Mesh > -class RiemannProblemInitialCondition -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Containers::StaticVector< Dimensions, RealType > PointType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; - - RiemannProblemInitialCondition() - : discontinuityPlacement( 0.5 ), - leftDensity( 1.0 ), rightDensity( 1.0 ), - leftVelocity( -2.0 ), rightVelocity( 2.0 ), - leftPressure( 0.4 ), rightPressure( 0.4 ), - gamma( 1.67 ){} - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "discontinuity-placement-0", "x-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-1", "y-coordinate of the discontinuity placement.", 0.5 ); - config.addEntry< double >( prefix + "discontinuity-placement-2", "z-coordinate of the discontinuity placement.", 0.5 ); -/* - config.addEntry< double >( prefix + "left-density", "Density on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-density", "Density on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-velocity-0", "x-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-1", "y-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "left-velocity-2", "z-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-velocity-0", "x-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-1", "y-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "right-velocity-2", "z-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); - config.addEntry< double >( prefix + "left-pressure", "Pressure on the left side of the discontinuity.", 1.0 ); - config.addEntry< double >( prefix + "right-pressure", "Pressure on the right side of the discontinuity.", 0.0 ); -*/ - config.addEntry< double >( prefix + "NWU-density", "This sets a value of northwest up density.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-0", "This sets a value of northwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-1", "This sets a value of northwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-velocity-2", "This sets a value of northwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWU-pressure", "This sets a value of northwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWU-density", "This sets a value of southwest up density.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-0", "This sets a value of southwest up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-1", "This sets a value of southwest up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-velocity-2", "This sets a value of southwest up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWU-pressure", "This sets a value of southwest up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NWD-density", "This sets a value of northwest down density.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-0", "This sets a value of northwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-1", "This sets a value of northwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-velocity-2", "This sets a value of northwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NWD-pressure", "This sets a value of northwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SWD-density", "This sets a value of southwest down density.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-0", "This sets a value of southwest down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-1", "This sets a value of southwest down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-velocity-2", "This sets a value of southwest down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SWD-pressure", "This sets a value of southwest down pressure.", 1.0 ); - config.addEntry< double >( prefix + "NEU-density", "This sets a value of northeast up density.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-0", "This sets a value of northeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-1", "This sets a value of northeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-velocity-2", "This sets a value of northeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NEU-pressure", "This sets a value of northeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "SEU-density", "This sets a value of southeast up density.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-0", "This sets a value of southeast up x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-1", "This sets a value of southeast up y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-velocity-2", "This sets a value of southeast up z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SEU-pressure", "This sets a value of southeast up pressure.", 1.0 ); - config.addEntry< double >( prefix + "NED-density", "This sets a value of northeast down density.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-0", "This sets a value of northeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-1", "This sets a value of northeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-velocity-2", "This sets a value of northeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "NED-pressure", "This sets a value of northeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "SED-density", "This sets a value of southeast down density.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-0", "This sets a value of southeast down x velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-1", "This sets a value of southeast down y velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-velocity-2", "This sets a value of southeast down z velocity.", 1.0 ); - config.addEntry< double >( prefix + "SED-pressure", "This sets a value of southeast down pressure.", 1.0 ); - config.addEntry< double >( prefix + "gamma", "Gamma in the ideal gas state equation.", 1.4 ); - - config.addEntry< String >( prefix + "initial", " One of predefined initial condition.", "none"); - config.addEntryEnum< String >( "none" ); - config.addEntryEnum< String >( "1D_2" ); - config.addEntryEnum< String >( "1D_3a" ); - config.addEntryEnum< String >( "1D_4" ); - config.addEntryEnum< String >( "1D_5" ); - config.addEntryEnum< String >( "1D_6" ); - config.addEntryEnum< String >( "1D_Noh" ); - config.addEntryEnum< String >( "1D_peak" ); - config.addEntryEnum< String >( "2D_3" ); - config.addEntryEnum< String >( "2D_4" ); - config.addEntryEnum< String >( "2D_6" ); - config.addEntryEnum< String >( "2D_12" ); - config.addEntryEnum< String >( "2D_15" ); - config.addEntryEnum< String >( "2D_17" ); - } - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - String initial = parameters.getParameter< String >( prefix + "initial" ); - if(initial == prefix + "none") - { - this->discontinuityPlacement.setup( parameters, prefix + "discontinuity-placement-" ); - this->gamma = parameters.getParameter< double >( prefix + "gamma" ); -/* - this->leftVelocity.setup( parameters, prefix + "left-velocity-" ); - this->rightVelocity.setup( parameters, prefix + "right-velocity-" ); - this->leftDensity = parameters.getParameter< double >( prefix + "left-density" ); - this->rightDensity = parameters.getParameter< double >( prefix + "right-density" ); - this->leftPressure = parameters.getParameter< double >( prefix + "left-pressure" ); - this->rightPressure = parameters.getParameter< double >( prefix + "right-pressure" ); -*/ - - this->NWUDensity = parameters.getParameter< RealType >( prefix + "NWU-density" ); - this->NWUVelocity.setup( parameters, prefix + "NWU-velocity-" ); - this->NWUPressure = parameters.getParameter< RealType >( prefix + "NWU-pressure" ); - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); - this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); - this->SWUPressure = parameters.getParameter< RealType >( prefix + "SWU-pressure" ); - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); - this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); - this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); - this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); - this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); - this->SWDPressure = parameters.getParameter< RealType >( prefix + "SWD-pressure" ); - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); - this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); - this->NEUPressure = parameters.getParameter< RealType >( prefix + "NEU-pressure" ); - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); - this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); - this->SEUPressure = parameters.getParameter< RealType >( prefix + "SEU-pressure" ); - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); - this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); - this->NEDPressure = parameters.getParameter< RealType >( prefix + "NED-pressure" ); - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); - this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); - this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - - } - if(initial == prefix + "1D_2") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -2.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_3a") - predefinedInitialCondition( 1.4, 0.8, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1000.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.01, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -19.59745, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -19.59745, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_4") - predefinedInitialCondition( 1.666, 0.4, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 5.99924, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 5.99242, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 460.894, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 46.095, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 19.5975, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -6.19633, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_5") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_6") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.1, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.1, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.1, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_Noh") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 0.000001, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 0.000001, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "1D_peak") - predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.0, 0.12612, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.0, 6.5915, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.0, 782.929, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.0, 3.15449, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 8.90470, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 2.26542, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_3") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5323, 0.138, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.5, 0.5323, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.3, 0.029, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.5, 0.3, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 1.206, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.206, 1.206, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.206, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_4") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5065, 1.1, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.1, 0.5065, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.35, 1.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.1, 0.35, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.8939, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.8939, 0.8939, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.8939, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_6") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 3.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.75, 0.5, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - -0.75, 0.5, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.75, -0.5, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - -0.75, -0.5, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_12") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 1.0, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 0.5313, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 0.4, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.7276, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 0.7276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - - if(initial == prefix + "2D_15") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 0.5197, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5313, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 0.4, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - -0.6259, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.1, -0.3, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.1, -0.3, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.1, 0.4276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - if(initial == prefix + "2D_17") - predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, - 0.0, 0.0, 2.0, 1.0625, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - 0.0, 0.0, 1.0, 0.5197, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - 0.0, 0.0, 1.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - 0.0, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 0.0, 0.2145, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - 0.0, -0.4, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 0.0, 1.1259, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ); - return true; - } - - void setDiscontinuityPlacement( const PointType& v ) - { - this->discontinuityPlacement = v; - } - - const PointType& getDiscontinuityPlasement() const - { - return this->discontinuityPlacement; - } - - void setLeftDensity( const RealType& leftDensity ) - { - this->leftDensity = leftDensity; - } - - const RealType& getLeftDensity() const - { - return this->leftDensity; - } - - void setRightDensity( const RealType& rightDensity ) - { - this->rightDensity = rightDensity; - } - - const RealType& getRightDensity() const - { - return this->rightDensity; - } - - void setLeftVelocity( const PointType& leftVelocity ) - { - this->leftVelocity = leftVelocity; - } - - const PointType& getLeftVelocity() const - { - return this->leftVelocity; - } - - void setRightVelocity( const RealType& rightVelocity ) - { - this->rightVelocity = rightVelocity; - } - - const PointType& getRightVelocity() const - { - return this->rightVelocity; - } - - void setLeftPressure( const RealType& leftPressure ) - { - this->leftPressure = leftPressure; - } - - const RealType& getLeftPressure() const - { - return this->leftPressure; - } - - void setRightPressure( const RealType& rightPressure ) - { - this->rightPressure = rightPressure; - } - - const RealType& getRightPressure() const - { - return this->rightPressure; - } - - - void predefinedInitialCondition( double preGamma, double preDiscX, double preDiscY, double preDiscZ, - double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, - double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, - double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, - double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, - double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, - double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, - double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, - double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, - double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, - double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ - ) - - { - this->discontinuityPlacement = PointLoad(preDiscX, preDiscY, preDiscZ); - this->gamma = preGamma; - - this->NWUDensity = preNWUDensity; - this->NWUVelocity = PointLoad(preNWUVelocityX, preNWUVelocityY, preNWUVelocityZ); - this->NWUPressure = preNWUPressure; - this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); - this->NWUMomentum = NWUVelocity * NWUDensity; - - this->SWUDensity = preNWUDensity; - this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); - this->SWUPressure = preSWUPressure; - this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); - this->SWUMomentum = SWUVelocity * SWUDensity; - - this->NWDDensity = preNWDDensity; - this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); - this->NWDPressure = preNWDPressure; - this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); - this->NWDMomentum = NWDVelocity * NWDDensity; - - this->SWDDensity = preSWDDensity; - this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); - this->SWDPressure = preSWDPressure; - this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); - this->SWDMomentum = SWDVelocity * SWDDensity; - - this->NEUDensity = preNEUDensity; - this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); - this->NEUPressure = preNEUPressure; - this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); - this->NEUMomentum = NEUVelocity * NEUDensity; - - this->SEUDensity = preSEUDensity; - this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); - this->SEUPressure = preSEUPressure; - this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); - this->SEUMomentum = SEUVelocity * SEUDensity; - - this->NEDDensity = preNEDDensity; - this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); - this->NEDPressure = preNEDPressure; - this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); - this->NEDMomentum = NEDVelocity * NEDDensity; - - this->SEDDensity = preSEDDensity; - this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); - this->SEDPressure = preSEDPressure; - this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); - this->SEDMomentum = SEDVelocity * SEDDensity; - - std::cout << this->SEDEnergy; - std::cout << this->SWDEnergy; - - } - - PointType PointLoad( RealType ValueX, RealType ValueY, RealType ValueZ) - { - PointType point; - switch (Dimensions) - { - case 1: point[ 0 ] = ValueX; - break; - case 2: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - break; - case 3: point[ 0 ] = ValueX; - point[ 1 ] = ValueY; - point[ 2 ] = ValueZ; - break; - } - return point; - } - - RealType Energy( RealType Density, RealType Pressure, RealType gamma, PointType Velocity) - { - RealType energy; - switch (Dimensions) - { - case 1: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ))); - break; - case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); - break; - case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 3 ], 2 ))); - break; // druhou mocninu ps8t jako sou4in - } - return energy; - } - - void setInitialCondition( CompressibleConservativeVariables< MeshType >& conservativeVariables, - const PointType& center = PointType( 0.0 ) ) - { - RiemannProblemInitialConditionSetter* variablesSetter = new RiemannProblemInitialConditionSetter; - variablesSetter->setGamma(this->gamma); - variablesSetter->setDensity(this->NWUDensity, - this->NEUDensity, - this->SWUDensity, - this->SEUDensity, - this->NWDDensity, - this->NEDDensity, - this->SWDDensity, - this->SEDDensity); - variablesSetter->setMomentum(this->NWUMomentum, - this->NEUMomentum, - this->SWUMomentum, - this->SEUMomentum, - this->NWDMomentum, - this->NEDMomentum, - this->SWDMomentum, - this->SEDMomentum); - variablesSetter->setEnergy(this->NWUEnergy, - this->NEUEnergy, - this->SWUEnergy, - this->SEUEnergy, - this->NWDEnergy, - this->NEDEnergy, - this->SWDEnergy, - this->SEDEnergy); - variablesSetter->setDiscontinuity(this->discontinuityPlacement); - variablesSetter->placeDensity(conservativeVariables); - variablesSetter->placeMomentum(conservativeVariables); - variablesSetter->placeEnergy(conservativeVariables); - -// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() -// typedef typename MeshType::Cell CellType -// typedef typename MeshType::CoordinatesType CoordinatesType -// Celltype cell(mesh, CoordinatesType(i,j)) -// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) -// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu - -/* - typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; - typedef Operators::Analytic::Sign< Dimensions, RealType > SignType; - typedef Functions::OperatorFunction< SignType, VectorNormType > InitialConditionType; - typedef Pointers::SharedPointer< InitialConditionType, DeviceType > InitialConditionPointer; - - InitialConditionPointer initialCondition; - initialCondition->getFunction().setCenter( center ); - initialCondition->getFunction().setMaxNorm( true ); - initialCondition->getFunction().setRadius( discontinuityPlacement[ 0 ] ); - discontinuityPlacement *= 1.0 / discontinuityPlacement[ 0 ]; - for( int i = 1; i < Dimensions; i++ ) - discontinuityPlacement[ i ] = 1.0 / discontinuityPlacement[ i ]; - initialCondition->getFunction().setAnisotropy( discontinuityPlacement ); - initialCondition->getFunction().setMultiplicator( -1.0 ); - - Functions::MeshFunctionEvaluator< MeshFunctionType, InitialConditionType > evaluator; -*/ - /**** - * Density - */ -/* - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ -/* - initialCondition->getOperator().setPositiveValue( leftDensity ); - initialCondition->getOperator().setNegativeValue( rightDensity ); - evaluator.evaluate( conservativeVariables.getDensity(), initialCondition ); - conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); -*/ - /**** - * Momentum - */ - -/* - for( int i = 0; i < Dimensions; i++ ) - { - initialCondition->getOperator().setPositiveValue( leftDensity * leftVelocity[ i ] ); - initialCondition->getOperator().setNegativeValue( rightDensity * rightVelocity[ i ] ); - evaluator.evaluate( conservativeVariables.getMomentum()[ i ], initialCondition ); - } -*/ - /**** - * Energy - */ -/* - conservativeVariables.getEnergy()->write( "energy-init", "gnuplot" ); -*/ -/* - const RealType leftKineticEnergy = leftVelocity.lpNorm( 2.0 ); - const RealType rightKineticEnergy = rightVelocity.lpNorm( 2.0 ); - const RealType leftEnergy = leftPressure / ( gamma - 1.0 ) + 0.5 * leftDensity * leftKineticEnergy * leftKineticEnergy; - const RealType rightEnergy = rightPressure / ( gamma - 1.0 ) + 0.5 * rightDensity * rightKineticEnergy * rightKineticEnergy; - initialCondition->getOperator().setPositiveValue( leftEnergy ); - initialCondition->getOperator().setNegativeValue( rightEnergy ); - evaluator.evaluate( (* conservativeVariables.getEnergy()), initialCondition ); - (* conservativeVariables.getEnergy())->write( "energy-init", "gnuplot" ); -*/ - } - - - protected: - - PointType discontinuityPlacement; - PointType NWUVelocity, NEUVelocity, SWUVelocity, SEUVelocity, NWDVelocity, NEDVelocity, SWDVelocity, SEDVelocity; - RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; - RealType NWUPressure, NEUPressure, SWUPressure, SEUPressure, NWDPressure, NEDPressure, SWDPressure, SEDPressure; - RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; - PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; - RealType leftDensity, rightDensity; - PointType leftVelocity, rightVelocity; - RealType leftPressure, rightPressure; - - RealType gamma; // gamma in the ideal gas state equation -}; - -} //namespace TNL diff --git a/src/Examples/flow-vl/Upwind.h b/src/Examples/flow-vl/Upwind.h deleted file mode 100644 index 5aee91b62..000000000 --- a/src/Examples/flow-vl/Upwind.h +++ /dev/null @@ -1,158 +0,0 @@ -/*************************************************************************** - Upwind.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "UpwindContinuity.h" -#include "UpwindEnergy.h" -#include "UpwindMomentumX.h" -#include "UpwindMomentumY.h" -#include "UpwindMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class Upwind -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef UpwindContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef UpwindMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef UpwindMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef UpwindMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef UpwindEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); - } - - Upwind() - :dynamicalViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); - this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); - - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setGamma( const RealType& gamma ) - { - this->continuityOperatorPointer->setGamma( gamma ); - this->momentumXOperatorPointer->setGamma( gamma ); - this->momentumYOperatorPointer->setGamma( gamma ); - this->momentumZOperatorPointer->setGamma( gamma ); - this->energyOperatorPointer->setGamma( gamma ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->continuityOperatorPointer->setPressure( pressure ); - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setDensity( const MeshFunctionPointer& density ) - { - this->momentumXOperatorPointer->setDensity( density ); - this->momentumYOperatorPointer->setDensity( density ); - this->momentumZOperatorPointer->setDensity( density ); - this->energyOperatorPointer->setDensity( density ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType dynamicalViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flow-vl/UpwindMomentumX.h b/src/Examples/flow-vl/UpwindMomentumX.h deleted file mode 100644 index edd375620..000000000 --- a/src/Examples/flow-vl/UpwindMomentumX.h +++ /dev/null @@ -1,433 +0,0 @@ -/*************************************************************************** - UpwindMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) - ) -// 1D T_11_x - - 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ) -// 2D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_21_y - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south - ) * hxInverse * hyInverse - ) * this->dynamicalViscosity; - - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) - ) -// 3D T_11_x - + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_21_x - + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity -// T_31_x - + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest - ) * hxInverse * hzInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-vl/UpwindMomentumY.h b/src/Examples/flow-vl/UpwindMomentumY.h deleted file mode 100644 index 4b5a7bcb2..000000000 --- a/src/Examples/flow-vl/UpwindMomentumY.h +++ /dev/null @@ -1,403 +0,0 @@ -/*************************************************************************** - UpwindMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ) -// 2D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - ) * this->dynamicalViscosity -// T_12_x - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east - ) * hxSquareInverse - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) - ) -// T_12_y - + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity -// 3D T_22_y - + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest - ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - ) * this->dynamicalViscosity -// T_32_y - + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth - ) * hyInverse * hzInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse - ) * this->dynamicalViscosity; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-vl/UpwindMomentumZ.h b/src/Examples/flow-vl/UpwindMomentumZ.h deleted file mode 100644 index 887eec977..000000000 --- a/src/Examples/flow-vl/UpwindMomentumZ.h +++ /dev/null @@ -1,338 +0,0 @@ -/*************************************************************************** - UpwindMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "UpwindMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "UpwindMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); - const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); - const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); - const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); - const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); - const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); - const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); - const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); - const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); - const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); - const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); - const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); - const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); - const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_northWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_x_northEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_x_southWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_x_southEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_x_upWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_x_downWest = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_x_upEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_x_downEast = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ downEast ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_northWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northWest ]; - const RealType& velocity_y_northEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ northEast ]; - const RealType& velocity_y_southWest = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southWest ]; - const RealType& velocity_y_southEast = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ southEast ]; - const RealType& velocity_y_upNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_y_upSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_y_downNorth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_y_downSouth = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ downSouth ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - const RealType& velocity_z_upWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upWest ]; - const RealType& velocity_z_upEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upEast ]; - const RealType& velocity_z_upNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upNorth ]; - const RealType& velocity_z_upSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ upSouth ]; - const RealType& velocity_z_downWest = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downWest ]; - const RealType& velocity_z_downEast = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downEast ]; - const RealType& velocity_z_downNorth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downNorth ]; - const RealType& velocity_z_downSouth = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) - - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) - ) -// T_13_z - + ( ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - + ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - ) - * this->dynamicalViscosity -// 3D T_33_z - + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) - * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) - * hxInverse * hzInverse / 4 - ) - * this->dynamicalViscosity; - } - - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flow-vl/navierStokes.h b/src/Examples/flow-vl/navierStokes.h deleted file mode 100644 index 0d37ad41c..000000000 --- a/src/Examples/flow-vl/navierStokes.h +++ /dev/null @@ -1,107 +0,0 @@ -#include -#include -#include -#include -#include -#include "navierStokesProblem.h" -#include "Upwind.h" -#include "navierStokesRhs.h" -#include "navierStokesBuildConfigTag.h" - -#include "RiemannProblemInitialCondition.h" -#include "BoundaryConditionsCavity.h" -#include "BoundaryConditionsBoiler.h" - -using namespace TNL; - -typedef navierStokesBuildConfigTag BuildConfig; - -/**** - * Uncomment the following (and comment the previous line) for the complete build. - * This will include support for all floating point precisions, all indexing types - * and more solvers. You may then choose between them from the command line. - * The compile time may, however, take tens of minutes or even several hours, - * especially if CUDA is enabled. Use this, if you want, only for the final build, - * not in the development phase. - */ -//typedef tnlDefaultConfigTag BuildConfig; - -template< typename ConfigTag >class navierStokesConfig -{ - public: - static void configSetup( Config::ConfigDescription & config ) - { - config.addDelimiter( "Inviscid flow settings:" ); - config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); - config.addEntryEnum< String >( "boiler" ); - config.addEntryEnum< String >( "cavity" ); - config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); - config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); - config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); - config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); - typedef Meshes::Grid< 3 > Mesh; - Upwind< Mesh >::configSetup( config, "inviscid-operators-" ); - RiemannProblemInitialCondition< Mesh >::configSetup( config ); - - /**** - * Add definition of your solver command line arguments. - */ - - } -}; - -template< typename Real, - typename Device, - typename Index, - typename MeshType, - typename ConfigTag, - typename SolverStarter, - typename Communicator > -class navierStokesSetter -{ - public: - - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - static bool run( const Config::ParameterContainer & parameters ) - { - enum { Dimension = MeshType::getMeshDimension() }; - typedef Upwind< MeshType, Real, Index > ApproximateOperator; - typedef navierStokesRhs< MeshType, Real > RightHandSide; - typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; - - /**** - * Resolve the template arguments of your solver here. - * The following code is for the Dirichlet and the Neumann boundary conditions. - * Both can be constant or defined as descrete values of Vector. - */ - typedef Functions::Analytic::Constant< Dimension, Real > Constant; - String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); - if( boundaryConditionsType == "cavity" ) - { - typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; - typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "boiler" ) - { - typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; - typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, ApproximateOperator, Communicator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - - return true;} - -}; - -int main( int argc, char* argv[] ) -{ - Solvers::Solver< navierStokesSetter, navierStokesConfig, BuildConfig > solver; - if( ! solver. run( argc, argv ) ) - return EXIT_FAILURE; - return EXIT_SUCCESS; -} diff --git a/src/Examples/flow-vl/navierStokesProblem_impl.h b/src/Examples/flow-vl/navierStokesProblem_impl.h deleted file mode 100644 index 886c9f03f..000000000 --- a/src/Examples/flow-vl/navierStokesProblem_impl.h +++ /dev/null @@ -1,458 +0,0 @@ -/*************************************************************************** - navierStokesProblem_impl.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -#include "RiemannProblemInitialCondition.h" -#include "CompressibleConservativeVariables.h" -#include "PhysicalVariablesGetter.h" -#include "navierStokesProblem.h" - -#include "UpwindContinuity.h" -#include "UpwindEnergy.h" -#include "UpwindMomentumX.h" -#include "UpwindMomentumY.h" -#include "UpwindMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -String -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getTypeStatic() -{ - return String( "navierStokesProblem< " ) + Mesh :: getTypeStatic() + " >"; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -String -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getPrologHeader() const -{ - return String( "Inviscid flow solver" ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const -{ - /**** - * Add data you want to have in the computation report (log) as follows: - * logger.writeParameter< double >( "Parameter description", parameter ); - */ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setup( const Config::ParameterContainer& parameters, - const String& prefix ) -{ - if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || - ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || - ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) - return false; - this->gamma = parameters.getParameter< double >( "gamma" ); - velocity->setMesh( this->getMesh() ); - pressure->setMesh( this->getMesh() ); - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -typename navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >::IndexType -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getDofs() const -{ - /**** - * Return number of DOFs (degrees of freedom) i.e. number - * of unknowns to be resolved by the main solver. - */ - return this->conservativeVariables->getDofs( this->getMesh() ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -bindDofs( DofVectorPointer& dofVector ) -{ - this->conservativeVariables->bind( this->getMesh(), dofVector ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ) -{ - CompressibleConservativeVariables< MeshType > conservativeVariables; - conservativeVariables.bind( this->getMesh(), dofs ); - const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); - this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); - this->speedIncrement = parameters.getParameter< RealType >( "speed-increment" ); - this->cavitySpeed = parameters.getParameter< RealType >( "cavity-speed" ); - if( initialConditionType == "riemann-problem" ) - { - RiemannProblemInitialCondition< MeshType > initialCondition; - if( ! initialCondition.setup( parameters ) ) - return false; - initialCondition.setInitialCondition( conservativeVariables ); - return true; - } - std::cerr << "Unknown initial condition " << initialConditionType << std::endl; - return false; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > - template< typename Matrix > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -setupLinearSystem( Matrix& matrix ) -{ -/* const IndexType dofs = this->getDofs( mesh ); - typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; - CompressedRowLengthsVectorType rowLengths; - if( ! rowLengths.setSize( dofs ) ) - return false; - MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; - matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, - differentialOperator, - boundaryCondition, - rowLengths ); - matrix.setDimensions( dofs, dofs ); - if( ! matrix.setCompressedRowLengths( rowLengths ) ) - return false;*/ - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ) -{ - std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; - - this->bindDofs( dofs ); - PhysicalVariablesGetter< MeshType > physicalVariablesGetter; - physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - FileName fileName; - fileName.setExtension( "tnl" ); - fileName.setIndex( step ); - fileName.setFileNameBase( "density-" ); - this->conservativeVariables->getDensity()->save( fileName.getFileName() ); - - fileName.setFileNameBase( "velocity-" ); - this->velocity->save( fileName.getFileName() ); - - fileName.setFileNameBase( "pressure-" ); - this->pressure->save( fileName.getFileName() ); - - /*fileName.setFileNameBase( "energy-" ); - if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) - return false; - - fileName.setFileNameBase( "momentum-" ); - if( ! this->conservativeVariables->getMomentum()->save( fileName.getFileName() ) ) - return false;*/ - - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ) -{ - typedef typename MeshType::Cell Cell; - const MeshPointer& mesh = this->getMesh(); - - /**** - * Bind DOFs - */ - this->conservativeVariables->bind( mesh, _u ); - this->conservativeVariablesRHS->bind( mesh, _fu ); - this->velocity->setMesh( mesh ); - this->pressure->setMesh( mesh ); - -// this->pressure->write( "pressure1", "gnuplot" ); -// getchar(); - /**** - * Resolve the physical variables - */ - PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; - physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - /**** - * Set-up operators - */ - typedef typename InviscidOperators::ContinuityOperatorType ContinuityOperatorType; - typedef typename InviscidOperators::MomentumXOperatorType MomentumXOperatorType; - typedef typename InviscidOperators::MomentumYOperatorType MomentumYOperatorType; - typedef typename InviscidOperators::MomentumZOperatorType MomentumZOperatorType; - typedef typename InviscidOperators::EnergyOperatorType EnergyOperatorType; - - this->inviscidOperatorsPointer->setTau( tau ); - this->inviscidOperatorsPointer->setVelocity( this->velocity ); - this->inviscidOperatorsPointer->setPressure( this->pressure ); - this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); - this->inviscidOperatorsPointer->setGamma( this->gamma ); - - /**** - * Set Up Boundary Conditions - */ - - typedef typename BoundaryCondition::DensityBoundaryConditionsType DensityBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumXBoundaryConditionsType MomentumXBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumYBoundaryConditionsType MomentumYBoundaryConditionsType; - typedef typename BoundaryCondition::MomentumZBoundaryConditionsType MomentumZBoundaryConditionsType; - typedef typename BoundaryCondition::EnergyBoundaryConditionsType EnergyBoundaryConditionsType; - - /**** - * Update Boundary Conditions - */ - if(this->speedIncrementUntil > time ) - { - this->boundaryConditionPointer->setTimestep(this->speedIncrement); - } - else - { - this->boundaryConditionPointer->setTimestep(0); - } - this->boundaryConditionPointer->setSpeed(this->cavitySpeed); - this->boundaryConditionPointer->setCompressibleConservativeVariables(this->conservativeVariables); - this->boundaryConditionPointer->setGamma(this->gamma); - this->boundaryConditionPointer->setPressure(this->pressure); - - - /**** - * Continuity equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, ContinuityOperatorType, DensityBoundaryConditionsType, RightHandSide > explicitUpdaterContinuity; - explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); - explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer->getDensityBoundaryCondition() ); - explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterContinuity.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - this->conservativeVariables->getDensity(), - this->conservativeVariablesRHS->getDensity() ); - - /**** - * Momentum equations - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumXOperatorType, MomentumXBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumX; - explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); - explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer->getMomentumXBoundaryCondition() ); - explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumX.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); - - if( Dimensions > 1 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumYOperatorType, MomentumYBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumY; - explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); - explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer->getMomentumYBoundaryCondition() ); - explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumY.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); - } - - if( Dimensions > 2 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, MomentumZBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumZ; - explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); - explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer->getMomentumZBoundaryCondition() ); - explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumZ.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); - } - - - /**** - * Energy equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, EnergyOperatorType, EnergyBoundaryConditionsType, RightHandSide > explicitUpdaterEnergy; - explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); - explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer->getEnergyBoundaryCondition() ); - explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterEnergy.template update< typename Mesh::Cell, CommunicatorType >( - time, tau, mesh, - this->conservativeVariablesRHS->getEnergy(), // uRhoVelocityX, - this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); - -/* this->pressure->write( "pressure3", "gnuplot" ); - getchar(); - this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); - this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); - this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); - getchar();*/ - -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > - template< typename Matrix > -void -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - Matrix& matrix, - DofVectorPointer& b ) -{ -/* LinearSystemAssembler< Mesh, - MeshFunctionType, - InviscidOperators, - BoundaryCondition, - RightHandSide, - BackwardTimeDiscretisation, - Matrix, - DofVectorType > systemAssembler; - - MeshFunction< Mesh > u( mesh, _u ); - systemAssembler.template assembly< typename Mesh::Cell >( time, - tau, - mesh, - this->differentialOperator, - this->boundaryCondition, - this->rightHandSide, - u, - matrix, - b );*/ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename InviscidOperators, - typename Communicator > -bool -navierStokesProblem< Mesh, BoundaryCondition, RightHandSide, InviscidOperators, Communicator >:: -postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ) -{ - /* - typedef typename MeshType::Cell Cell; - int count = mesh->template getEntitiesCount< Cell >()/4; - //bind _u - this->_uRho.bind( *dofs, 0, count); - this->_uRhoVelocityX.bind( *dofs, count, count); - this->_uRhoVelocityY.bind( *dofs, 2 * count, count); - this->_uEnergy.bind( *dofs, 3 * count, count); - - MeshFunctionType velocity( mesh, this->velocity ); - MeshFunctionType velocityX( mesh, this->velocityX ); - MeshFunctionType velocityY( mesh, this->velocityY ); - MeshFunctionType pressure( mesh, this->pressure ); - MeshFunctionType uRho( mesh, _uRho ); - MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); - MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); - MeshFunctionType uEnergy( mesh, _uEnergy ); - //Generating differential operators - Velocity navierStokes2DVelocity; - VelocityX navierStokes2DVelocityX; - VelocityY navierStokes2DVelocityY; - Pressure navierStokes2DPressure; - - //velocityX - navierStokes2DVelocityX.setRhoVelX(uRhoVelocityX); - navierStokes2DVelocityX.setRho(uRho); -// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; -// velocityX = OFVelocityX; - - //velocityY - navierStokes2DVelocityY.setRhoVelY(uRhoVelocityY); - navierStokes2DVelocityY.setRho(uRho); -// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; -// velocityY = OFVelocityY; - - //velocity - navierStokes2DVelocity.setVelX(velocityX); - navierStokes2DVelocity.setVelY(velocityY); -// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; -// velocity = OFVelocity; - - //pressure - navierStokes2DPressure.setGamma(gamma); - navierStokes2DPressure.setVelocity(velocity); - navierStokes2DPressure.setEnergy(uEnergy); - navierStokes2DPressure.setRho(uRho); -// OperatorFunction< navierStokes2DPressure, MeshFunction, void, time > OFPressure; -// pressure = OFPressure; - */ - return true; -} - -} // namespace TNL - diff --git a/src/Examples/flow/BoundaryConditionsBoiler.h b/src/Examples/flow/BoundaryConditionsBoiler.h deleted file mode 100644 index f61f988da..000000000 --- a/src/Examples/flow/BoundaryConditionsBoiler.h +++ /dev/null @@ -1,137 +0,0 @@ -#include - -#include "DensityBoundaryConditionBoiler.h" -#include "MomentumXBoundaryConditionBoiler.h" -#include "MomentumYBoundaryConditionBoiler.h" -#include "MomentumZBoundaryConditionBoiler.h" -#include "EnergyBoundaryConditionBoiler.h" - -namespace TNL { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class BoundaryConditionsBoiler -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef Index IndexType; - typedef Function FunctionType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef typename Mesh::DeviceType DeviceType; - - typedef TNL::Operators::DensityBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; - typedef TNL::Operators::MomentumXBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; - typedef TNL::Operators::MomentumYBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; - typedef TNL::Operators::MomentumZBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; - typedef TNL::Operators::EnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - - typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - return true; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - } - - void setTimestep(const RealType timestep) - { - this->densityBoundaryConditionsPointer->setTimestep(timestep); - this->momentumXBoundaryConditionsPointer->setTimestep(timestep); - this->momentumYBoundaryConditionsPointer->setTimestep(timestep); - this->momentumZBoundaryConditionsPointer->setTimestep(timestep); - this->energyBoundaryConditionsPointer->setTimestep(timestep); - } - - void setGamma(const RealType gamma) - { - this->densityBoundaryConditionsPointer->setGamma(gamma); - this->momentumXBoundaryConditionsPointer->setGamma(gamma); - this->momentumYBoundaryConditionsPointer->setGamma(gamma); - this->momentumZBoundaryConditionsPointer->setGamma(gamma); - this->energyBoundaryConditionsPointer->setGamma(gamma); - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->densityBoundaryConditionsPointer->setPressure(pressure); - this->momentumXBoundaryConditionsPointer->setPressure(pressure); - this->momentumYBoundaryConditionsPointer->setPressure(pressure); - this->momentumZBoundaryConditionsPointer->setPressure(pressure); - this->energyBoundaryConditionsPointer->setPressure(pressure); - } - - void setSpeed(const RealType cavitySpeed) - { - this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - } - - DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() - { - return this->densityBoundaryConditionsPointer; - } - - MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() - { - return this->momentumXBoundaryConditionsPointer; - } - - MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() - { - return this->momentumYBoundaryConditionsPointer; - } - - MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() - { - return this->momentumZBoundaryConditionsPointer; - } - - EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() - { - return this->energyBoundaryConditionsPointer; - } - - - protected: - DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; - MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; - MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; - MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; - EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; - -}; - -} //namespace TNL diff --git a/src/Examples/flow/BoundaryConditionsCavity.h b/src/Examples/flow/BoundaryConditionsCavity.h deleted file mode 100644 index bbae2d3e9..000000000 --- a/src/Examples/flow/BoundaryConditionsCavity.h +++ /dev/null @@ -1,137 +0,0 @@ -#include - -#include "DensityBoundaryConditionCavity.h" -#include "MomentumXBoundaryConditionCavity.h" -#include "MomentumYBoundaryConditionCavity.h" -#include "MomentumZBoundaryConditionCavity.h" -#include "EnergyBoundaryConditionCavity.h" - -namespace TNL { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class BoundaryConditionsCavity -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef Index IndexType; - typedef Function FunctionType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef typename Mesh::DeviceType DeviceType; - - typedef TNL::Operators::DensityBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; - typedef TNL::Operators::MomentumXBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; - typedef TNL::Operators::MomentumYBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; - typedef TNL::Operators::MomentumZBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; - typedef TNL::Operators::EnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - - typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - } - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); - return true; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); - } - - void setTimestep(const RealType timestep) - { - this->densityBoundaryConditionsPointer->setTimestep(timestep); - this->momentumXBoundaryConditionsPointer->setTimestep(timestep); - this->momentumYBoundaryConditionsPointer->setTimestep(timestep); - this->momentumZBoundaryConditionsPointer->setTimestep(timestep); - this->energyBoundaryConditionsPointer->setTimestep(timestep); - } - - void setGamma(const RealType gamma) - { - this->densityBoundaryConditionsPointer->setGamma(gamma); - this->momentumXBoundaryConditionsPointer->setGamma(gamma); - this->momentumYBoundaryConditionsPointer->setGamma(gamma); - this->momentumZBoundaryConditionsPointer->setGamma(gamma); - this->energyBoundaryConditionsPointer->setGamma(gamma); - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->densityBoundaryConditionsPointer->setPressure(pressure); - this->momentumXBoundaryConditionsPointer->setPressure(pressure); - this->momentumYBoundaryConditionsPointer->setPressure(pressure); - this->momentumZBoundaryConditionsPointer->setPressure(pressure); - this->energyBoundaryConditionsPointer->setPressure(pressure); - } - - void setSpeed(const RealType cavitySpeed) - { - this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - } - - DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() - { - return this->densityBoundaryConditionsPointer; - } - - MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() - { - return this->momentumXBoundaryConditionsPointer; - } - - MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() - { - return this->momentumYBoundaryConditionsPointer; - } - - MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() - { - return this->momentumZBoundaryConditionsPointer; - } - - EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() - { - return this->energyBoundaryConditionsPointer; - } - - - protected: - DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; - MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; - MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; - MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; - EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; - -}; - -} //namespace TNL diff --git a/src/Examples/flow/DensityBoundaryConditionBoiler.h b/src/Examples/flow/DensityBoundaryConditionBoiler.h deleted file mode 100644 index 6231f6780..000000000 --- a/src/Examples/flow/DensityBoundaryConditionBoiler.h +++ /dev/null @@ -1,542 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class DensityBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class DensityBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return u[ neighborEntities.template getEntityIndex< 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if (entity.getCoordinates().y() < 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class DensityBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public DensityBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if (entity.getCoordinates().z() < 0.8 * ( entity.getMesh().getDimensions().z() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType gamma; - MeshFunctionPointer pressure; - -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionBoilers: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow/EnergyBoundaryConditionBoiler.h b/src/Examples/flow/EnergyBoundaryConditionBoiler.h deleted file mode 100644 index a99fdf015..000000000 --- a/src/Examples/flow/EnergyBoundaryConditionBoiler.h +++ /dev/null @@ -1,854 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class EnergyBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function> -class EnergyBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed - * - this->cavitySpeed - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - * - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - );*/ - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - * - this->cavitySpeed * ( -1 ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - ); - else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - );*/ - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - + - this->cavitySpeed - * - this->cavitySpeed - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - );*/ - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - + 0 - ) - );*/ - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class EnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public EnergyBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - * - this->cavitySpeed - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - * - this->cavitySpeed * ( -1 ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - * - this->cavitySpeed - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - * - this->cavitySpeed * ( -1 ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) -{ - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * - ( - ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - + 0 - ) - + - ( - this->cavitySpeed - * - this->cavitySpeed - ) - ); - - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow/MomentumXBoundaryConditionBoiler.h b/src/Examples/flow/MomentumXBoundaryConditionBoiler.h deleted file mode 100644 index dfe63e076..000000000 --- a/src/Examples/flow/MomentumXBoundaryConditionBoiler.h +++ /dev/null @@ -1,594 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumXBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumXBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - ); - else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - );*/ - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - );*/ - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - ); - else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow/MomentumXBoundaryConditionCavity.h b/src/Examples/flow/MomentumXBoundaryConditionCavity.h deleted file mode 100644 index 07abfdbeb..000000000 --- a/src/Examples/flow/MomentumXBoundaryConditionCavity.h +++ /dev/null @@ -1,570 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumXBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumXBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - );*/ - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - * ( - ( this->cavitySpeed/* - * ( - entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) - ) - / ( entity.getMesh().getDimensions().x() / 2 )*/ - ) - ); - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumXBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumXBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow/MomentumYBoundaryConditionBoiler.h b/src/Examples/flow/MomentumYBoundaryConditionBoiler.h deleted file mode 100644 index 83b6282dd..000000000 --- a/src/Examples/flow/MomentumYBoundaryConditionBoiler.h +++ /dev/null @@ -1,588 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumYBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumYBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - );*/ - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - );*/ - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) - &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow/MomentumYBoundaryConditionCavity.h b/src/Examples/flow/MomentumYBoundaryConditionCavity.h deleted file mode 100644 index a83dd653f..000000000 --- a/src/Examples/flow/MomentumYBoundaryConditionCavity.h +++ /dev/null @@ -1,564 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumYBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumYBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - );*/ - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - );*/ - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumYBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumYBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow/MomentumZBoundaryConditionBoiler.h b/src/Examples/flow/MomentumZBoundaryConditionBoiler.h deleted file mode 100644 index 9d887857c..000000000 --- a/src/Examples/flow/MomentumZBoundaryConditionBoiler.h +++ /dev/null @@ -1,563 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumZBoundaryConditionsBoiler -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumZBoundaryConditionsBoilerBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsBoilerBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) - &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] - * ( - this->cavitySpeed - ); - else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow/MomentumZBoundaryConditionCavity.h b/src/Examples/flow/MomentumZBoundaryConditionCavity.h deleted file mode 100644 index 5fe6f22e5..000000000 --- a/src/Examples/flow/MomentumZBoundaryConditionCavity.h +++ /dev/null @@ -1,554 +0,0 @@ -/*************************************************************************** - IdentityOperator.h - description - ------------------- - begin : Nov 17, 2014 - copyright : (C) 2014 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include - -namespace TNL { -namespace Operators { - -template< typename Mesh, - typename Function, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::GlobalIndexType > -class MomentumZBoundaryConditionsCavity -{ - -}; - -/**** - * Base - */ -template< typename Function > -class MomentumZBoundaryConditionsCavityBase -{ - public: - - typedef Function FunctionType; - - static void configSetup( const Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - } - - template< typename MeshPointer > - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); - } - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - Function::configSetup( config, prefix ); - }; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return this->function.setup( parameters, prefix ); - }; - - void setFunction( const FunctionType& function ) - { - this->function = function; - }; - - FunctionType& getFunction() - { - return this->function; - } - - const FunctionType& getFunction() const - { - return this->function; - }; - - protected: - - FunctionType function; - -}; - -/**** - * 1D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 1, 1, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 1, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] - + this->timestep - ); - else - return u[ neighborEntities.template getEntityIndex< -1 >() ]; - - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - else - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 2D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 2, 2, - Real, - Index > - -{ - public: - - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 2, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - } - } - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -/**** - * 3D grid - */ -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Function, - typename Real, - typename Index > -class MomentumZBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > - : public MomentumZBoundaryConditionsCavityBase< Function >, - public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - Functions::MeshBoundaryDomain, - 3, 3, - Real, - Index > -{ - public: - - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - typedef Function FunctionType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; - typedef Containers::StaticVector< 3, RealType > PointType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; - typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; - typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; - typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - - template< typename EntityType, - typename MeshFunction > - __cuda_callable__ - const RealType operator()( const MeshFunction& u, - const EntityType& entity, - const RealType& time = 0 ) const - { - const MeshType& mesh = entity.getMesh(); - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - if( entity.getCoordinates().x() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - if( entity.getCoordinates().z() == 0 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - // The following line is commented to avoid compiler warning - //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; - } - } - - - template< typename EntityType > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const EntityType& entity ) const - { - return 2; - } - - template< typename PreimageFunction, - typename MeshEntity, - typename Matrix, - typename Vector > - __cuda_callable__ - void setMatrixElements( const PreimageFunction& u, - const MeshEntity& entity, - const RealType& time, - const RealType& tau, - Matrix& matrix, - Vector& b ) const - { - const auto& neighborEntities = entity.getNeighborEntities(); - const IndexType& index = entity.getIndex(); - typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); - if( entity.getCoordinates().x() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().x() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().y() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == 0 ) - { - matrixRow.setElement( 0, index, 1.0 ); - matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) - { - matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); - matrixRow.setElement( 1, index, 1.0 ); - b[ index ] = entity.getMesh().getSpaceSteps().z() * - Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); - } - } - - void setTimestep(const RealType timestep ) - { - this->timestep = timestep; - } - - void setGamma(const RealType gamma ) - { - this->gamma = gamma; - } - - void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) - { - this->compressibleConservativeVariables = compressibleConservativeVariables; - } - - void setPressure(const MeshFunctionPointer& pressure) - { - this->pressure = pressure; - } - - void setCavitySpeed(const RealType cavitySpeed) - { - this->cavitySpeed = cavitySpeed; - } - - private: - CompressibleConservativeVariablesPointer compressibleConservativeVariables; - RealType timestep; - RealType cavitySpeed; - RealType gamma; - MeshFunctionPointer pressure; -}; - -template< typename Mesh, - typename Function, - typename Real, - typename Index > -std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) -{ - str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); - return str; -} - -} // namespace Operators -} // namespace TNL - diff --git a/src/Examples/flow/navierStokes.cpp b/src/Examples/flow/navierStokes.cpp deleted file mode 100644 index 7dffcb059..000000000 --- a/src/Examples/flow/navierStokes.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "navierStokes.h" diff --git a/src/Examples/flow/navierStokes.cu b/src/Examples/flow/navierStokes.cu deleted file mode 100644 index 7dffcb059..000000000 --- a/src/Examples/flow/navierStokes.cu +++ /dev/null @@ -1 +0,0 @@ -#include "navierStokes.h" diff --git a/src/Examples/flow/navierStokesBuildConfigTag.h b/src/Examples/flow/navierStokesBuildConfigTag.h deleted file mode 100644 index 9267843d5..000000000 --- a/src/Examples/flow/navierStokesBuildConfigTag.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef navierStokesBUILDCONFIGTAG_H_ -#define navierStokesBUILDCONFIGTAG_H_ - -#include - -namespace TNL { - -class navierStokesBuildConfigTag{}; - -namespace Solvers { - -/**** - * Turn off support for float and long double. - */ -template<> struct ConfigTagReal< navierStokesBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct ConfigTagReal< navierStokesBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct ConfigTagIndex< navierStokesBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct ConfigTagIndex< navierStokesBuildConfigTag, long int >{ enum { enabled = false }; }; - -/**** - * Please, chose your preferred time discretisation here. - */ -template<> struct ConfigTagTimeDiscretisation< navierStokesBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; -template<> struct ConfigTagTimeDiscretisation< navierStokesBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; -template<> struct ConfigTagTimeDiscretisation< navierStokesBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; - -/**** - * Only the Runge-Kutta-Merson solver is enabled by default. - */ -template<> struct ConfigTagExplicitSolver< navierStokesBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; - -} // namespace Solvers - -namespace Meshes { -namespace BuildConfigTags { - -template< int Dimensions > struct GridDimensionTag< navierStokesBuildConfigTag, Dimensions >{ enum { enabled = ( Dimensions == 1 ) }; }; - -/**** - * Turn off support for float and long double. - */ -template<> struct GridRealTag< navierStokesBuildConfigTag, float > { enum { enabled = false }; }; -template<> struct GridRealTag< navierStokesBuildConfigTag, long double > { enum { enabled = false }; }; - -/**** - * Turn off support for short int and long int indexing. - */ -template<> struct GridIndexTag< navierStokesBuildConfigTag, short int >{ enum { enabled = false }; }; -template<> struct GridIndexTag< navierStokesBuildConfigTag, long int >{ enum { enabled = false }; }; - -} // namespace BuildConfigTags -} // namespace Meshes - -} // namespace TNL - -#endif /* navierStokesBUILDCONFIGTAG_H_ */ diff --git a/src/Examples/flow/navierStokesRhs.h b/src/Examples/flow/navierStokesRhs.h deleted file mode 100644 index 3c82ad453..000000000 --- a/src/Examples/flow/navierStokesRhs.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef navierStokesRHS_H_ -#define navierStokesRHS_H_ - -#include - -namespace TNL { - -template< typename Mesh, typename Real >class navierStokesRhs - : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > - { - public: - - typedef Mesh MeshType; - typedef Real RealType; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; - } - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const Real& time = 0.0 ) const - { - typedef typename MeshEntity::MeshType::PointType PointType; - PointType v = entity.getCenter(); - return 0.0; - } -}; - -} //namespace TNL - -#endif /* navierStokesRHS_H_ */ diff --git a/src/Examples/flows/CMakeLists.txt b/src/Examples/flows/CMakeLists.txt index d1ab7b055..041f2c15d 100644 --- a/src/Examples/flows/CMakeLists.txt +++ b/src/Examples/flows/CMakeLists.txt @@ -1,29 +1,3 @@ -#euler -# -#set( tnl_inviscid_flow_HEADERS -# CompressibleConservativeVariables.h ) -# -#set( tnl_inviscid_flow_SOURCES -# euler.cpp -# euler.cu ) -# -#IF( BUILD_CUDA ) -# CUDA_ADD_EXECUTABLE(tnl-euler euler.cu) -# target_link_libraries (tnl-euler tnl ${CUSPARSE_LIBRARY} ) -#ELSE( BUILD_CUDA ) -# ADD_EXECUTABLE(tnl-euler euler.cpp) -# target_link_libraries (tnl-euler tnl ) -#ENDIF( BUILD_CUDA ) -# -# -#INSTALL( TARGETS tnl-euler -# RUNTIME DESTINATION bin -# PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) -# -#INSTALL( FILES run-euler -# ${tnl_inviscid_flow_SOURCES} -# DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/inviscid-flow ) -# #navier-stokes set( tnl_flow_HEADERS diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h deleted file mode 100644 index 329cc243c..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h +++ /dev/null @@ -1,149 +0,0 @@ -/*************************************************************************** - LaxFridrichs.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichs -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef LaxFridrichsContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); - } - - LaxFridrichs() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); - this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); - - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setGamma( const RealType& gamma ) - { - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setDensity( const MeshFunctionPointer& density ) - { - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h deleted file mode 100644 index b4836ab74..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsContinuity.h +++ /dev/null @@ -1,297 +0,0 @@ -/*************************************************************************** - LaxFridrichsContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsContinuityBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - RealType artificialViscosity; -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) - - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse - + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h deleted file mode 100644 index 3bfb98285..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsEnergy.h +++ /dev/null @@ -1,320 +0,0 @@ -/*************************************************************************** - LaxFridrichsEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east - - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse; - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse - + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) - -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h deleted file mode 100644 index cc2561748..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumBase.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsMomentumBase() - : artificialViscosity( 1.0 ){}; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h deleted file mode 100644 index 35e75cff1..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumX.h +++ /dev/null @@ -1,286 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - //const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - //const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - //const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - //const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_u[ up ] * velocity_z_up ) - - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h deleted file mode 100644 index 9c6308385..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumY.h +++ /dev/null @@ -1,268 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse - + ( ( rho_v[ up ] * velocity_z_up ) - - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h b/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h deleted file mode 100644 index d67532b56..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichsMomentumZ.h +++ /dev/null @@ -1,245 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) - -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) - - ( rho_w[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_w[ north ] * velocity_y_north ) - - ( rho_w[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) - - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h deleted file mode 100644 index 204ff3059..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarming.h +++ /dev/null @@ -1,151 +0,0 @@ -/*************************************************************************** - StegerWarming.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "StegerWarmingContinuity.h" -#include "StegerWarmingEnergy.h" -#include "StegerWarmingMomentumX.h" -#include "StegerWarmingMomentumY.h" -#include "StegerWarmingMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class StegerWarming -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef StegerWarmingContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef StegerWarmingMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef StegerWarmingMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef StegerWarmingMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef StegerWarmingEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - } - - StegerWarming() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setGamma( const RealType& gamma ) - { - this->continuityOperatorPointer->setGamma( gamma ); - this->momentumXOperatorPointer->setGamma( gamma ); - this->momentumYOperatorPointer->setGamma( gamma ); - this->momentumZOperatorPointer->setGamma( gamma ); - this->energyOperatorPointer->setGamma( gamma ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->continuityOperatorPointer->setPressure( pressure ); - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setDensity( const MeshFunctionPointer& density ) - { - this->momentumXOperatorPointer->setDensity( density ); - this->momentumYOperatorPointer->setDensity( density ); - this->momentumZOperatorPointer->setDensity( density ); - this->energyOperatorPointer->setDensity( density ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h deleted file mode 100644 index e64ffd50c..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingContinuity.h +++ /dev/null @@ -1,381 +0,0 @@ -/*************************************************************************** - StegerWarmingContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class StegerWarmingContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - static String getType() - { - return String( "StegerWarmingContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); - else - return density * velocity; - }; - - RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); - else - return 0.0; - }; - - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class StegerWarmingContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) - - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) - - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) - + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) - ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h deleted file mode 100644 index c9c75c9f5..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingEnergy.h +++ /dev/null @@ -1,540 +0,0 @@ -/*************************************************************************** - StegerWarmingEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class StegerWarmingEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - StegerWarmingEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "StegerWarmingEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; - - MeshFunctionPointer density; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class StegerWarmingEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) - ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - + ( machNumber * ( machNumber + 1.0 ) ) - + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) - * ( - ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) - - ( machNumber * ( machNumber - 1.0 ) ) - + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h deleted file mode 100644 index cf95cda18..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumBase.h +++ /dev/null @@ -1,130 +0,0 @@ -/*************************************************************************** - StegerWarmingMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class StegerWarmingMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber + 1.0 ) * ( machNumber + 1.0 ) ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber + 1.0 ) * (machNumber + 1.0 ) ); - else - return density * velocity * velocity + pressure; - }; - - RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity * velocity + pressure; - else if ( machNumber <= 0.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber - 1.0 ) * (machNumber - 1.0 ) ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber - 1.0 ) * ( machNumber - 1.0 ) ); - else - return 0; - }; - - RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * velocity_other; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * velocity_other; - else - return density * velocity_main * velocity_other; - }; - - RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity_main * velocity_other; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * velocity_other; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * velocity_other; - else - return 0.0; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - MeshFunctionPointer density; - -}; - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h deleted file mode 100644 index 62b999e79..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumX.h +++ /dev/null @@ -1,343 +0,0 @@ -/*************************************************************************** - StegerWarmingMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "StegerWarmingMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class StegerWarmingMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "StegerWarmingMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "StegerWarmingMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ); - - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "StegerWarmingMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h deleted file mode 100644 index 342a6f0ea..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumY.h +++ /dev/null @@ -1,318 +0,0 @@ -/*************************************************************************** - StegerWarmingMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "StegerWarmingMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class StegerWarmingMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "StegerWarmingMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "StegerWarmingMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "StegerWarmingMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h deleted file mode 100644 index 95064b241..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/Steger-Warming/StegerWarmingMomentumZ.h +++ /dev/null @@ -1,276 +0,0 @@ -/*************************************************************************** - StegerWarmingMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "StegerWarmingMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class StegerWarmingMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "StegerWarmingMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "StegerWarmingMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef StegerWarmingMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "StegerWarmingMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) - - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) - ); - } - - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h deleted file mode 100644 index eff60cc5b..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeer.h +++ /dev/null @@ -1,151 +0,0 @@ -/*************************************************************************** - VanLeer.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "VanLeerContinuity.h" -#include "VanLeerEnergy.h" -#include "VanLeerMomentumX.h" -#include "VanLeerMomentumY.h" -#include "VanLeerMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class VanLeer -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef VanLeerContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef VanLeerMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef VanLeerMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef VanLeerMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef VanLeerEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - } - - VanLeer() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setGamma( const RealType& gamma ) - { - this->continuityOperatorPointer->setGamma( gamma ); - this->momentumXOperatorPointer->setGamma( gamma ); - this->momentumYOperatorPointer->setGamma( gamma ); - this->momentumZOperatorPointer->setGamma( gamma ); - this->energyOperatorPointer->setGamma( gamma ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->continuityOperatorPointer->setPressure( pressure ); - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setDensity( const MeshFunctionPointer& density ) - { - this->momentumXOperatorPointer->setDensity( density ); - this->momentumYOperatorPointer->setDensity( density ); - this->momentumZOperatorPointer->setDensity( density ); - this->energyOperatorPointer->setDensity( density ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h deleted file mode 100644 index e8628ad38..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerContinuity.h +++ /dev/null @@ -1,382 +0,0 @@ -/*************************************************************************** - VanLeerContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class VanLeerContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - static String getType() - { - return String( "VanLeerContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); - else - return density * velocity; - }; - - RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity; - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); - else - return 0.0; - }; - - RealType multiply (const RealType& a, const RealType& b ) const - { - return a * b; - }; - - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class VanLeerContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) - - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) - - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) - + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) - ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h deleted file mode 100644 index b6aa75fa5..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerEnergy.h +++ /dev/null @@ -1,504 +0,0 @@ -/*************************************************************************** - VanLeerEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class VanLeerEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - VanLeerEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "VanLeerEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; - - MeshFunctionPointer density; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class VanLeerEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) - * ( - 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) - * ( - 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) - ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + velocity_other2 * velocity_other2 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - }; - - RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) - * ( - velocity_other1 * velocity_other1 / 2.0 - + velocity_other2 * velocity_other2 / 2.0 - + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) - ); - else - return 0.0; - }; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) - - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) - ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h deleted file mode 100644 index 7e6867a3e..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumBase.h +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************** - VanLeerMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class VanLeerMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setDensity( const MeshFunctionPointer& density ) - { - this->density = density; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); - else - return density * velocity * velocity + pressure; - }; - - RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity * velocity + pressure; - else if ( machNumber <= 1.0 ) - return - density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * ( - 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); - else - return 0; - }; - - RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 1.0 ) - return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * velocity_other; - else - return density * velocity_main * velocity_other; - }; - - RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const - { - const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity_main / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity_main * velocity_other; - else if ( machNumber <= 1.0 ) - return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * velocity_other; - else - return 0.0; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - MeshFunctionPointer density; - -}; - -} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h deleted file mode 100644 index 28ae3e808..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumX.h +++ /dev/null @@ -1,343 +0,0 @@ -/*************************************************************************** - VanLeerMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "VanLeerMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class VanLeerMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "VanLeerMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "VanLeerMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ); - - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "VanLeerMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) - - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) - + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h deleted file mode 100644 index 8fb8f7aff..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumY.h +++ /dev/null @@ -1,318 +0,0 @@ -/*************************************************************************** - VanLeerMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "VanLeerMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class VanLeerMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "VanLeerMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "VanLeerMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "VanLeerMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) - - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) - + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) - - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h b/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h deleted file mode 100644 index 600b566e7..000000000 --- a/src/Examples/flows/DifferentialOperators/Euler/VanLeer/VanLeerMomentumZ.h +++ /dev/null @@ -1,276 +0,0 @@ -/*************************************************************************** - VanLeerMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "VanLeerMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class VanLeerMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "VanLeerMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "VanLeerMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef VanLeerMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "VanLeerMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; - const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; - const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; - const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; - const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; - const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; - const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) - - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) - + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) - - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) - + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) - ); - } - - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/flows/euler.cpp b/src/Examples/flows/euler.cpp deleted file mode 100644 index 4d76005cb..000000000 --- a/src/Examples/flows/euler.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "euler.h" diff --git a/src/Examples/flows/euler.cu b/src/Examples/flows/euler.cu deleted file mode 100644 index 4d76005cb..000000000 --- a/src/Examples/flows/euler.cu +++ /dev/null @@ -1 +0,0 @@ -#include "euler.h" diff --git a/src/Examples/flows/euler.h b/src/Examples/flows/euler.h deleted file mode 100644 index 6abae004a..000000000 --- a/src/Examples/flows/euler.h +++ /dev/null @@ -1,134 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "eulerProblem.h" -#include "DifferentialOperators/Euler/Lax-Friedrichs/LaxFridrichs.h" -#include "DifferentialOperators/Euler/Steger-Warming/StegerWarming.h" -#include "DifferentialOperators/Euler/VanLeer/VanLeer.h" -#include "flowsRhs.h" -#include "flowsBuildConfigTag.h" - -#include "RiemannProblemInitialCondition.h" - -using namespace TNL; - -typedef flowsBuildConfigTag BuildConfig; - -/**** - * Uncomment the following (and comment the previous line) for the complete build. - * This will include support for all floating point precisions, all indexing types - * and more solvers. You may then choose between them from the command line. - * The compile time may, however, take tens of minutes or even several hours, - * especially if CUDA is enabled. Use this, if you want, only for the final build, - * not in the development phase. - */ -//typedef tnlDefaultConfigTag BuildConfig; - -template< typename ConfigTag >class eulerConfig -{ - public: - static void configSetup( Config::ConfigDescription & config ) - { - config.addDelimiter( "Inviscid flow settings:" ); - config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "dirichlet"); - config.addEntryEnum< String >( "dirichlet" ); - config.addEntryEnum< String >( "neumann" ); - config.addEntry< String >( "differential-operator", "Choose the differential operator.", "Lax-Friedrichs"); - config.addEntryEnum< String >( "Lax-Friedrichs" ); - config.addEntryEnum< String >( "Steger-Warming" ); - config.addEntryEnum< String >( "VanLeer" ); - config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); - typedef Meshes::Grid< 3 > Mesh; - LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); - RiemannProblemInitialCondition< Mesh >::configSetup( config ); - - /**** - * Add definition of your solver command line arguments. - */ - - } -}; - -template< typename Real, - typename Device, - typename Index, - typename MeshType, - typename ConfigTag, - typename SolverStarter, - typename CommunicatorType > -class eulerSetter -{ - public: - - typedef Real RealType; - typedef Device DeviceType; - typedef Index IndexType; - - static bool run( const Config::ParameterContainer & parameters ) - { - enum { Dimension = MeshType::getMeshDimension() }; - typedef LaxFridrichs< MeshType, Real, Index > ApproximateOperator; - typedef flowsRhs< MeshType, Real > RightHandSide; - typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; - String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); - if( differentialOperatorType == "Lax-Friedrichs" ) - typedef LaxFridrichs< MeshType, Real, Index > ApproximateOperator; - else if( differentialOperatorType == "Steger-Warming" ) - typedef StegerWarming< MeshType, Real, Index > ApproximateOperator; - else if( differentialOperatorType == "VanLeer" ) - typedef VanLeer< MeshType, Real, Index > ApproximateOperator; - - /**** - * Resolve the template arguments of your solver here. - * The following code is for the Dirichlet and the Neumann boundary conditions. - * Both can be constant or defined as descrete values of Vector. - */ - String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); - if( parameters.checkParameter( "boundary-conditions-constant" ) ) - { - typedef Functions::Analytic::Constant< Dimension, Real > Constant; - if( boundaryConditionsType == "dirichlet" ) - { - typedef Operators::DirichletBoundaryConditions< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "neumann" ) - { - typedef Operators::NeumannBoundaryConditions< MeshType, Constant, Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - } - typedef Functions::MeshFunction< MeshType > MeshFunction; - if( boundaryConditionsType == "dirichlet" ) - { - typedef Operators::DirichletBoundaryConditions< MeshType, MeshFunction, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "neumann" ) - { - typedef Operators::NeumannBoundaryConditions< MeshType, MeshFunction, Real, Index > BoundaryConditions; - typedef eulerProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - - return true;} - -}; - -int main( int argc, char* argv[] ) -{ - Solvers::Solver< eulerSetter, eulerConfig, BuildConfig > solver; - if( ! solver. run( argc, argv ) ) - return EXIT_FAILURE; - return EXIT_SUCCESS; -} diff --git a/src/Examples/flows/eulerProblem.h b/src/Examples/flows/eulerProblem.h deleted file mode 100644 index bf1d6f3d0..000000000 --- a/src/Examples/flows/eulerProblem.h +++ /dev/null @@ -1,119 +0,0 @@ -/*************************************************************************** - eulerProblem.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include "CompressibleConservativeVariables.h" - - -using namespace TNL::Problems; - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -class eulerProblem: - public PDEProblem< Mesh, - Communicator, - typename InviscidOperators::RealType, - typename Mesh::DeviceType, - typename InviscidOperators::IndexType > -{ - public: - - typedef typename InviscidOperators::RealType RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef typename InviscidOperators::IndexType IndexType; - typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; - - typedef Communicator CommunicatorType; - - using typename BaseType::MeshType; - using typename BaseType::MeshPointer; - using typename BaseType::DofVectorType; - using typename BaseType::DofVectorPointer; - static const int Dimensions = Mesh::getMeshDimension(); - - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; - typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; - typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; - - - static String getType(); - - String getPrologHeader() const; - - void writeProlog( Logger& logger, - const Config::ParameterContainer& parameters ) const; - - bool setup( const Config::ParameterContainer& parameters, - const String& prefix = "" ); - - bool setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ); - - template< typename Matrix > - bool setupLinearSystem( Matrix& matrix ); - - bool makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ); - - IndexType getDofs() const; - - void bindDofs( DofVectorPointer& dofs ); - - void getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ); - - template< typename Matrix > - void assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs, - Matrix& matrix, - DofVectorPointer& rightHandSide ); - - bool postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ); - - protected: - - InviscidOperatorsPointer inviscidOperatorsPointer; - - BoundaryConditionPointer boundaryConditionPointer; - RightHandSidePointer rightHandSidePointer; - - ConservativeVariablesPointer conservativeVariables, - conservativeVariablesRHS; - - VelocityFieldPointer velocity; - MeshFunctionPointer pressure; - - RealType gamma; -}; - -} // namespace TNL - -#include "eulerProblem_impl.h" - diff --git a/src/Examples/flows/eulerProblem_impl.h b/src/Examples/flows/eulerProblem_impl.h deleted file mode 100644 index d54261143..000000000 --- a/src/Examples/flows/eulerProblem_impl.h +++ /dev/null @@ -1,416 +0,0 @@ -/*************************************************************************** - eulerProblem_impl.h - description - ------------------- - begin : Feb 13, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include -#include - -#include "RiemannProblemInitialCondition.h" -#include "CompressibleConservativeVariables.h" -#include "PhysicalVariablesGetter.h" -#include "eulerProblem.h" - -//#include "LaxFridrichsContinuity.h" -//#include "LaxFridrichsEnergy.h" -//#include "LaxFridrichsMomentumX.h" -//#include "LaxFridrichsMomentumY.h" -//#include "LaxFridrichsMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getType() -{ - return String( "eulerProblem< " ) + Mesh :: getType() + " >"; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -String -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getPrologHeader() const -{ - return String( "flow solver" ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const -{ - /**** - * Add data you want to have in the computation report (log) as follows: - * logger.writeParameter< double >( "Parameter description", parameter ); - */ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -setup( const Config::ParameterContainer& parameters, - const String& prefix ) -{ - if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || - ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || - ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) - return false; - this->gamma = parameters.getParameter< double >( "gamma" ); - velocity->setMesh( this->getMesh() ); - pressure->setMesh( this->getMesh() ); - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -typename eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >::IndexType -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getDofs() const -{ - /**** - * Return number of DOFs (degrees of freedom) i.e. number - * of unknowns to be resolved by the main solver. - */ - return this->conservativeVariables->getDofs( this->getMesh() ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -bindDofs( DofVectorPointer& dofVector ) -{ - this->conservativeVariables->bind( this->getMesh(), dofVector ); -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -setInitialCondition( const Config::ParameterContainer& parameters, - DofVectorPointer& dofs ) -{ - CompressibleConservativeVariables< MeshType > conservativeVariables; - conservativeVariables.bind( this->getMesh(), dofs ); - const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); - if( initialConditionType == "riemann-problem" ) - { - RiemannProblemInitialCondition< MeshType > initialCondition; - if( ! initialCondition.setup( parameters ) ) - return false; - initialCondition.setInitialCondition( conservativeVariables ); - return true; - } - std::cerr << "Unknown initial condition " << initialConditionType << std::endl; - return false; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > - template< typename Matrix > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -setupLinearSystem( Matrix& matrix ) -{ -/* const IndexType dofs = this->getDofs(); - typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; - CompressedRowLengthsVectorType rowLengths; - if( ! rowLengths.setSize( dofs ) ) - return false; - MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; - matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, - differentialOperator, - boundaryCondition, - rowLengths ); - matrix.setDimensions( dofs, dofs ); - if( ! matrix.setCompressedRowLengths( rowLengths ) ) - return false;*/ - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -makeSnapshot( const RealType& time, - const IndexType& step, - DofVectorPointer& dofs ) -{ - std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; - - this->bindDofs( dofs ); - PhysicalVariablesGetter< MeshType > physicalVariablesGetter; - physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - FileName fileName; - fileName.setExtension( "tnl" ); - fileName.setIndex( step ); - fileName.setFileNameBase( "density-" ); - if( ! this->conservativeVariables->getDensity()->save( fileName.getFileName() ) ) - return false; - - fileName.setFileNameBase( "velocity-" ); - if( ! this->velocity->save( fileName.getFileName() ) ) - return false; - - fileName.setFileNameBase( "pressure-" ); - if( ! this->pressure->save( fileName.getFileName() ) ) - return false; - - fileName.setFileNameBase( "energy-" ); - if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) - return false; - - return true; -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -getExplicitUpdate( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - DofVectorPointer& _fu ) -{ - typedef typename MeshType::Cell Cell; - - /**** - * Bind DOFs - */ - this->conservativeVariables->bind( this->getMesh(), _u ); - this->conservativeVariablesRHS->bind( this->getMesh(), _fu ); - this->velocity->setMesh( this->getMesh() ); - this->pressure->setMesh( this->getMesh() ); - - /**** - * Resolve the physical variables - */ - PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; - physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); - physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - - /**** - * Set-up operators - */ - typedef typename InviscidOperators::ContinuityOperatorType ContinuityOperatorType; - typedef typename InviscidOperators::MomentumXOperatorType MomentumXOperatorType; - typedef typename InviscidOperators::MomentumYOperatorType MomentumYOperatorType; - typedef typename InviscidOperators::MomentumZOperatorType MomentumZOperatorType; - typedef typename InviscidOperators::EnergyOperatorType EnergyOperatorType; - - this->inviscidOperatorsPointer->setTau( tau ); - this->inviscidOperatorsPointer->setVelocity( this->velocity ); - this->inviscidOperatorsPointer->setPressure( this->pressure ); - this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); - this->inviscidOperatorsPointer->setGamma( this->gamma ); - - /**** - * Continuity equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, ContinuityOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterContinuity; - explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); - explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - this->conservativeVariables->getDensity(), - this->conservativeVariablesRHS->getDensity() ); - - /**** - * Momentum equations - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumXOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumX; - explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); - explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); - - if( Dimensions > 1 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumYOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumY; - explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); - explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); - } - - if( Dimensions > 2 ) - { - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, MomentumZOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterMomentumZ; - explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); - explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, - ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); - } - - - /**** - * Energy equation - */ - Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, EnergyOperatorType, BoundaryCondition, RightHandSide > explicitUpdaterEnergy; - explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); - explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer ); - explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); - explicitUpdaterEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), - this->conservativeVariables->getEnergy(), // uRhoVelocityX, - this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); - - /*this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); - this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); - this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); - getchar();*/ - -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > - template< typename Matrix > -void -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -assemblyLinearSystem( const RealType& time, - const RealType& tau, - DofVectorPointer& _u, - Matrix& matrix, - DofVectorPointer& b ) -{ -/* LinearSystemAssembler< Mesh, - MeshFunctionType, - InviscidOperators, - BoundaryCondition, - RightHandSide, - BackwardTimeDiscretisation, - Matrix, - DofVectorType > systemAssembler; - - MeshFunction< Mesh > u( mesh, _u ); - systemAssembler.template assembly< typename Mesh::Cell >( time, - tau, - this->differentialOperator, - this->boundaryCondition, - this->rightHandSide, - u, - matrix, - b );*/ -} - -template< typename Mesh, - typename BoundaryCondition, - typename RightHandSide, - typename Communicator, - typename InviscidOperators > -bool -eulerProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: -postIterate( const RealType& time, - const RealType& tau, - DofVectorPointer& dofs ) -{ - /* - typedef typename MeshType::Cell Cell; - int count = mesh->template getEntitiesCount< Cell >()/4; - //bind _u - this->_uRho.bind( *dofs, 0, count); - this->_uRhoVelocityX.bind( *dofs, count, count); - this->_uRhoVelocityY.bind( *dofs, 2 * count, count); - this->_uEnergy.bind( *dofs, 3 * count, count); - - MeshFunctionType velocity( mesh, this->velocity ); - MeshFunctionType velocityX( mesh, this->velocityX ); - MeshFunctionType velocityY( mesh, this->velocityY ); - MeshFunctionType pressure( mesh, this->pressure ); - MeshFunctionType uRho( mesh, _uRho ); - MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); - MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); - MeshFunctionType uEnergy( mesh, _uEnergy ); - //Generating differential operators - Velocity euler2DVelocity; - VelocityX euler2DVelocityX; - VelocityY euler2DVelocityY; - Pressure euler2DPressure; - - //velocityX - euler2DVelocityX.setRhoVelX(uRhoVelocityX); - euler2DVelocityX.setRho(uRho); -// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; -// velocityX = OFVelocityX; - - //velocityY - euler2DVelocityY.setRhoVelY(uRhoVelocityY); - euler2DVelocityY.setRho(uRho); -// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; -// velocityY = OFVelocityY; - - //velocity - euler2DVelocity.setVelX(velocityX); - euler2DVelocity.setVelY(velocityY); -// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; -// velocity = OFVelocity; - - //pressure - euler2DPressure.setGamma(gamma); - euler2DPressure.setVelocity(velocity); - euler2DPressure.setEnergy(uEnergy); - euler2DPressure.setRho(uRho); -// OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure; -// pressure = OFPressure; - */ - return true; -} - -} // namespace TNL - diff --git a/src/Examples/flows/run-euler b/src/Examples/flows/run-euler deleted file mode 100644 index 9ebf9cbb5..000000000 --- a/src/Examples/flows/run-euler +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 2 \ - --origin-x 0.0 \ - --origin-y 0.0 \ - --proportions-x 1.0 \ - --proportions-y 1.0 \ - --size-x 100 \ - --size-y 100 - -tnl-init --test-function sin-wave \ - --output-file init.tnl -tnl-euler-2d --initial-condition riemann-problem \ - --discontinuity-placement-0 0.3 \ - --discontinuity-placement-1 0.3 \ - --discontinuity-placement-2 0.3 \ - --time-discretisation explicit \ - --boundary-conditions-type neumann \ - --boundary-conditions-constant 0 \ - --discrete-solver euler \ - --time-step 0.0001 \ - --snapshot-period 0.01 \ - --final-time 1.0 - -tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/flows/run-navier-stokes b/src/Examples/flows/run-navier-stokes index 9ebf9cbb5..cd0c1bbb1 100644 --- a/src/Examples/flows/run-navier-stokes +++ b/src/Examples/flows/run-navier-stokes @@ -8,18 +8,33 @@ tnl-grid-setup --dimensions 2 \ --size-x 100 \ --size-y 100 -tnl-init --test-function sin-wave \ - --output-file init.tnl -tnl-euler-2d --initial-condition riemann-problem \ - --discontinuity-placement-0 0.3 \ - --discontinuity-placement-1 0.3 \ - --discontinuity-placement-2 0.3 \ - --time-discretisation explicit \ - --boundary-conditions-type neumann \ - --boundary-conditions-constant 0 \ - --discrete-solver euler \ - --time-step 0.0001 \ - --snapshot-period 0.01 \ - --final-time 1.0 +tnl-euler-navier-stokes + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --differential-operator Steger-Warming \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/inviscid-flow-sw/UpwindContinuity.h b/src/Examples/inviscid-flow-sw/UpwindContinuity.h deleted file mode 100644 index 22fc4ffc5..000000000 --- a/src/Examples/inviscid-flow-sw/UpwindContinuity.h +++ /dev/null @@ -1,382 +0,0 @@ -/*************************************************************************** - UpwindContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - static String getType() - { - return String( "UpwindContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setGamma(const Real& gamma) - { - this->gamma = gamma; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - __cuda_callable__ - RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = TNL::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return 0.0; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); - else - return density * velocity; - }; - - __cuda_callable__ - RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const - { - const RealType& speedOfSound = TNL::sqrt( this->gamma * pressure / density ); - const RealType& machNumber = velocity / speedOfSound; - if ( machNumber <= -1.0 ) - return density * velocity; - else if ( machNumber <= 0.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); - else if ( machNumber <= 1.0 ) - return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); - else - return 0.0; - }; - - protected: - - RealType tau; - - RealType gamma; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class UpwindContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class UpwindContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public UpwindContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef UpwindContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_center = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - - const RealType& velocity_y_center = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - const RealType& velocity_z_center = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return -hxInverse * ( - this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) - - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) - - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) - + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) - ) - -hyInverse * ( - this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) - + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ) - -hzInverse * ( - this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) - - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) - - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) - + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) - ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/inviscid-flow-vl/CompressibleConservativeVariables.h b/src/Examples/inviscid-flow-vl/CompressibleConservativeVariables.h deleted file mode 100644 index 01e820686..000000000 --- a/src/Examples/inviscid-flow-vl/CompressibleConservativeVariables.h +++ /dev/null @@ -1,147 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -namespace TNL { - -template< typename Mesh > -class CompressibleConservativeVariables -{ - public: - typedef Mesh MeshType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; - - CompressibleConservativeVariables(){}; - - CompressibleConservativeVariables( const MeshPointer& meshPointer ) - : density( meshPointer ), - momentum( meshPointer ), - //pressure( meshPointer ), - energy( meshPointer ){}; - - void setMesh( const MeshPointer& meshPointer ) - { - this->density->setMesh( meshPointer ); - this->momentum->setMesh( meshPointer ); - //this->pressure.setMesh( meshPointer ); - this->energy->setMesh( meshPointer ); - } - - template< typename Vector > - void bind( const MeshPointer& meshPointer, - const Vector& data, - IndexType offset = 0 ) - { - IndexType currentOffset( offset ); - this->density->bind( meshPointer, data, currentOffset ); - currentOffset += this->density->getDofs( meshPointer ); - for( IndexType i = 0; i < Dimensions; i++ ) - { - ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); - currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); - } - this->energy->bind( meshPointer, data, currentOffset ); - } - - IndexType getDofs( const MeshPointer& meshPointer ) const - { - return this->density->getDofs( meshPointer ) + - this->momentum->getDofs( meshPointer ) + - this->energy->getDofs( meshPointer ); - } - - MeshFunctionPointer& getDensity() - { - return this->density; - } - - const MeshFunctionPointer& getDensity() const - { - return this->density; - } - - void setDensity( MeshFunctionPointer& density ) - { - this->density = density; - } - - MomentumFieldPointer& getMomentum() - { - return this->momentum; - } - - const MomentumFieldPointer& getMomentum() const - { - return this->momentum; - } - - void setMomentum( MomentumFieldPointer& momentum ) - { - this->momentum = momentum; - } - - /*MeshFunctionPointer& getPressure() - { - return this->pressure; - } - - const MeshFunctionPointer& getPressure() const - { - return this->pressure; - } - - void setPressure( MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }*/ - - MeshFunctionPointer& getEnergy() - { - return this->energy; - } - - const MeshFunctionPointer& getEnergy() const - { - return this->energy; - } - - void setEnergy( MeshFunctionPointer& energy ) - { - this->energy = energy; - } - - void getVelocityField( VelocityFieldType& velocityField ) - { - - } - - protected: - - MeshFunctionPointer density; - MomentumFieldPointer momentum; - MeshFunctionPointer energy; - -}; - -} // namespace TN diff --git a/src/Examples/inviscid-flow-vl/PhysicalVariablesGetter.h b/src/Examples/inviscid-flow-vl/PhysicalVariablesGetter.h deleted file mode 100644 index d7eeb7618..000000000 --- a/src/Examples/inviscid-flow-vl/PhysicalVariablesGetter.h +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { - -template< typename Mesh > -class PhysicalVariablesGetter -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - VelocityGetter( MeshFunctionPointer density, - MeshFunctionPointer momentum ) - : density( density ), momentum( momentum ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) - return 0; - else - return momentum.template getData< DeviceType >()( meshEntity ) / - density.template getData< DeviceType >()( meshEntity ); - } - - protected: - const MeshFunctionPointer density, momentum; - }; - - class PressureGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - PressureGetter( MeshFunctionPointer density, - MeshFunctionPointer energy, - VelocityFieldPointer momentum, - const RealType& gamma ) - : density( density ), energy( energy ), momentum( momentum ), gamma( gamma ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - const RealType e = energy.template getData< DeviceType >()( meshEntity ); - const RealType rho = density.template getData< DeviceType >()( meshEntity ); - const RealType momentumNorm = lpNorm( momentum.template getData< DeviceType >().getVector( meshEntity ), 2.0 ); - if( rho == 0.0 ) - return 0; - else - return ( gamma - 1.0 ) * ( e - 0.5 * momentumNorm * momentumNorm / rho ); - } - - protected: - const MeshFunctionPointer density, energy; - const VelocityFieldPointer momentum; - const RealType gamma; - }; - - - void getVelocity( const ConservativeVariablesPointer& conservativeVariables, - VelocityFieldPointer& velocity ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; - for( int i = 0; i < Dimensions; i++ ) - { - Pointers::SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), - ( *conservativeVariables->getMomentum() )[ i ] ); - evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); - } - } - - void getPressure( const ConservativeVariablesPointer& conservativeVariables, - const RealType& gamma, - MeshFunctionPointer& pressure ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; - Pointers::SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), - conservativeVariables->getEnergy(), - conservativeVariables->getMomentum(), - gamma ); - evaluator.evaluate( pressure, pressureGetter ); - } - -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow/CompressibleConservativeVariables.h b/src/Examples/inviscid-flow/CompressibleConservativeVariables.h deleted file mode 100644 index ca77bb281..000000000 --- a/src/Examples/inviscid-flow/CompressibleConservativeVariables.h +++ /dev/null @@ -1,147 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -namespace TNL { - -template< typename Mesh > -class CompressibleConservativeVariables -{ - public: - typedef Mesh MeshType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; - - CompressibleConservativeVariables(){}; - - CompressibleConservativeVariables( const MeshPointer& meshPointer ) - : density( meshPointer ), - momentum( meshPointer ), - //pressure( meshPointer ), - energy( meshPointer ){}; - - void setMesh( const MeshPointer& meshPointer ) - { - this->density->setMesh( meshPointer ); - this->momentum->setMesh( meshPointer ); - //this->pressure.setMesh( meshPointer ); - this->energy->setMesh( meshPointer ); - } - - template< typename Vector > - void bind( const MeshPointer& meshPointer, - const Vector& data, - IndexType offset = 0 ) - { - IndexType currentOffset( offset ); - this->density->bind( meshPointer, data, currentOffset ); - currentOffset += this->density->getDofs( meshPointer ); - for( IndexType i = 0; i < Dimensions; i++ ) - { - ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); - currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); - } - this->energy->bind( meshPointer, data, currentOffset ); - } - - IndexType getDofs( const MeshPointer& meshPointer ) const - { - return this->density->getDofs( meshPointer ) + - this->momentum->getDofs( meshPointer ) + - this->energy->getDofs( meshPointer ); - } - - MeshFunctionPointer& getDensity() - { - return this->density; - } - - const MeshFunctionPointer& getDensity() const - { - return this->density; - } - - void setDensity( MeshFunctionPointer& density ) - { - this->density = density; - } - - MomentumFieldPointer& getMomentum() - { - return this->momentum; - } - - const MomentumFieldPointer& getMomentum() const - { - return this->momentum; - } - - void setMomentum( MomentumFieldPointer& momentum ) - { - this->momentum = momentum; - } - - /*MeshFunctionPointer& getPressure() - { - return this->pressure; - } - - const MeshFunctionPointer& getPressure() const - { - return this->pressure; - } - - void setPressure( MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }*/ - - MeshFunctionPointer& getEnergy() - { - return this->energy; - } - - const MeshFunctionPointer& getEnergy() const - { - return this->energy; - } - - void setEnergy( MeshFunctionPointer& energy ) - { - this->energy = energy; - } - - void getVelocityField( VelocityFieldType& velocityField ) - { - - } - - protected: - - MeshFunctionPointer density; - MomentumFieldPointer momentum; - MeshFunctionPointer energy; - -}; - -} // namespace TN \ No newline at end of file diff --git a/src/Examples/inviscid-flow/LaxFridrichs.h b/src/Examples/inviscid-flow/LaxFridrichs.h deleted file mode 100644 index 1a648234a..000000000 --- a/src/Examples/inviscid-flow/LaxFridrichs.h +++ /dev/null @@ -1,141 +0,0 @@ -/*************************************************************************** - LaxFridrichs.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include - -#include "LaxFridrichsContinuity.h" -#include "LaxFridrichsEnergy.h" -#include "LaxFridrichsMomentumX.h" -#include "LaxFridrichsMomentumY.h" -#include "LaxFridrichsMomentumZ.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichs -{ - public: - typedef Mesh MeshType; - typedef Real RealType; - typedef typename Mesh::DeviceType DeviceType; - typedef Index IndexType; - typedef Functions::MeshFunction< Mesh > MeshFunctionType; - static const int Dimensions = Mesh::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; - - typedef LaxFridrichsContinuity< Mesh, Real, Index > ContinuityOperatorType; - typedef LaxFridrichsMomentumX< Mesh, Real, Index > MomentumXOperatorType; - typedef LaxFridrichsMomentumY< Mesh, Real, Index > MomentumYOperatorType; - typedef LaxFridrichsMomentumZ< Mesh, Real, Index > MomentumZOperatorType; - typedef LaxFridrichsEnergy< Mesh, Real, Index > EnergyOperatorType; - - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; - typedef Pointers::SharedPointer< MeshType > MeshPointer; - - typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; - typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; - typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; - typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; - typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; - - static void configSetup( Config::ConfigDescription& config, - const String& prefix = "" ) - { - config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); - } - - LaxFridrichs() - : artificialViscosity( 1.0 ) {} - - bool setup( const MeshPointer& meshPointer, - const Config::ParameterContainer& parameters, - const String& prefix = "" ) - { - this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); - this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); - this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); - - return true; - } - - void setTau( const RealType& tau ) - { - this->continuityOperatorPointer->setTau( tau ); - this->momentumXOperatorPointer->setTau( tau ); - this->momentumYOperatorPointer->setTau( tau ); - this->momentumZOperatorPointer->setTau( tau ); - this->energyOperatorPointer->setTau( tau ); - } - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->momentumXOperatorPointer->setPressure( pressure ); - this->momentumYOperatorPointer->setPressure( pressure ); - this->momentumZOperatorPointer->setPressure( pressure ); - this->energyOperatorPointer->setPressure( pressure ); - } - - void setVelocity( const VectorFieldPointer& velocity ) - { - this->continuityOperatorPointer->setVelocity( velocity ); - this->momentumXOperatorPointer->setVelocity( velocity ); - this->momentumYOperatorPointer->setVelocity( velocity ); - this->momentumZOperatorPointer->setVelocity( velocity ); - this->energyOperatorPointer->setVelocity( velocity ); - } - - const ContinuityOperatorPointer& getContinuityOperator() const - { - return this->continuityOperatorPointer; - } - - const MomentumXOperatorPointer& getMomentumXOperator() const - { - return this->momentumXOperatorPointer; - } - - const MomentumYOperatorPointer& getMomentumYOperator() const - { - return this->momentumYOperatorPointer; - } - - const MomentumZOperatorPointer& getMomentumZOperator() const - { - return this->momentumZOperatorPointer; - } - - const EnergyOperatorPointer& getEnergyOperator() const - { - return this->energyOperatorPointer; - } - - protected: - - ContinuityOperatorPointer continuityOperatorPointer; - MomentumXOperatorPointer momentumXOperatorPointer; - MomentumYOperatorPointer momentumYOperatorPointer; - MomentumZOperatorPointer momentumZOperatorPointer; - EnergyOperatorPointer energyOperatorPointer; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow/LaxFridrichsContinuity.h b/src/Examples/inviscid-flow/LaxFridrichsContinuity.h deleted file mode 100644 index 0ae10b4f9..000000000 --- a/src/Examples/inviscid-flow/LaxFridrichsContinuity.h +++ /dev/null @@ -1,288 +0,0 @@ -/*************************************************************************** - LaxFridrichsContinuity.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include - -namespace TNL { - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuityBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsContinuityBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsContinuity< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - RealType artificialViscosity; -}; - - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsContinuity -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) - - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsContinuityBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) - - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse - + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse - + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ); - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/inviscid-flow/LaxFridrichsEnergy.h b/src/Examples/inviscid-flow/LaxFridrichsEnergy.h deleted file mode 100644 index 8c6791cd1..000000000 --- a/src/Examples/inviscid-flow/LaxFridrichsEnergy.h +++ /dev/null @@ -1,309 +0,0 @@ -/*************************************************************************** - LaxFridrichsEnergy.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergyBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsEnergyBase() - : artificialViscosity( 1.0 ){}; - - static String getType() - { - return String( "LaxFridrichsEnergy< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsEnergy -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) - - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east - - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse; - - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsEnergyBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& e, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) - - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) - -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse - + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) - -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse - + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) - -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow/LaxFridrichsMomentumBase.h b/src/Examples/inviscid-flow/LaxFridrichsMomentumBase.h deleted file mode 100644 index 96488da1a..000000000 --- a/src/Examples/inviscid-flow/LaxFridrichsMomentumBase.h +++ /dev/null @@ -1,68 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumBase.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumBase -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - LaxFridrichsMomentumBase() - : artificialViscosity( 1.0 ){}; - - void setTau(const Real& tau) - { - this->tau = tau; - }; - - void setVelocity( const VelocityFieldPointer& velocity ) - { - this->velocity = velocity; - }; - - void setPressure( const MeshFunctionPointer& pressure ) - { - this->pressure = pressure; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; - } - - protected: - - RealType tau; - - VelocityFieldPointer velocity; - - MeshFunctionPointer pressure; - - RealType artificialViscosity; -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow/LaxFridrichsMomentumX.h b/src/Examples/inviscid-flow/LaxFridrichsMomentumX.h deleted file mode 100644 index 63def12d3..000000000 --- a/src/Examples/inviscid-flow/LaxFridrichsMomentumX.h +++ /dev/null @@ -1,276 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumX.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumX -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - - return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) - - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumX< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_u, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; - const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; - //const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - //const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - //const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - //const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) - - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) - - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse - + ( ( rho_u[ north ] * velocity_y_north ) - - ( rho_u[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_u[ up ] * velocity_z_up ) - - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow/LaxFridrichsMomentumY.h b/src/Examples/inviscid-flow/LaxFridrichsMomentumY.h deleted file mode 100644 index 8ce42282d..000000000 --- a/src/Examples/inviscid-flow/LaxFridrichsMomentumY.h +++ /dev/null @@ -1,260 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumY.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumY -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - - return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumY< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_v, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; - const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) - - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) - - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse - + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) - - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse - + ( ( rho_v[ up ] * velocity_z_up ) - - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow/LaxFridrichsMomentumZ.h b/src/Examples/inviscid-flow/LaxFridrichsMomentumZ.h deleted file mode 100644 index a67e862ce..000000000 --- a/src/Examples/inviscid-flow/LaxFridrichsMomentumZ.h +++ /dev/null @@ -1,240 +0,0 @@ -/*************************************************************************** - LaxFridrichsMomentumZ.h - description - ------------------- - begin : Feb 18, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include "LaxFridrichsMomentumBase.h" - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class LaxFridrichsMomentumZ -{ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); - //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); - - return 0.0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > - : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef LaxFridrichsMomentumBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::MeshFunctionPointer; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - static String getType() - { - return String( "LaxFridrichsMomentumZ< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - template< typename MeshFunction, typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshFunction& rho_w, - const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); - static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); - const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); - - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - const IndexType& center = entity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; - const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; - const RealType& velocity_x_east = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_x_west = this->velocity.template getData< DeviceType >()[ 0 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_north = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_y_south = this->velocity.template getData< DeviceType >()[ 1 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_up = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_z_down = this->velocity.template getData< DeviceType >()[ 2 ].template getData< DeviceType >()[ down ]; - return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * - ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) - -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) - - ( rho_w[ west ] * velocity_x_west ) )* hxInverse - + ( ( rho_w[ north ] * velocity_y_north ) - - ( rho_w[ south ] * velocity_y_south ) )* hyInverse - + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) - - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} // namespace TNL - diff --git a/src/Examples/inviscid-flow/PhysicalVariablesGetter.h b/src/Examples/inviscid-flow/PhysicalVariablesGetter.h deleted file mode 100644 index a0a7f672d..000000000 --- a/src/Examples/inviscid-flow/PhysicalVariablesGetter.h +++ /dev/null @@ -1,122 +0,0 @@ -/*************************************************************************** - CompressibleConservativeVariables.h - description - ------------------- - begin : Feb 12, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - -#pragma once - -#include -#include -#include -#include -#include "CompressibleConservativeVariables.h" - -namespace TNL { - -template< typename Mesh > -class PhysicalVariablesGetter -{ - public: - - typedef Mesh MeshType; - typedef typename MeshType::RealType RealType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::IndexType IndexType; - static const int Dimensions = MeshType::getMeshDimension(); - - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; - typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - - class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - VelocityGetter( MeshFunctionPointer density, - MeshFunctionPointer momentum ) - : density( density ), momentum( momentum ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) - return 0; - else - return momentum.template getData< DeviceType >()( meshEntity ) / - density.template getData< DeviceType >()( meshEntity ); - } - - protected: - const MeshFunctionPointer density, momentum; - }; - - class PressureGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > - { - public: - typedef typename MeshType::RealType RealType; - - PressureGetter( MeshFunctionPointer density, - MeshFunctionPointer energy, - VelocityFieldPointer momentum, - const RealType& gamma ) - : density( density ), energy( energy ), momentum( momentum ), gamma( gamma ) {} - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - const RealType e = energy.template getData< DeviceType >()( meshEntity ); - const RealType rho = density.template getData< DeviceType >()( meshEntity ); - const RealType momentumNorm = lpNorm( momentum.template getData< DeviceType >().getVector( meshEntity ), 2.0 ); - if( rho == 0.0 ) - return 0; - else - return ( gamma - 1.0 ) * ( e - 0.5 * momentumNorm * momentumNorm / rho ); - } - - protected: - const MeshFunctionPointer density, energy; - const VelocityFieldPointer momentum; - const RealType gamma; - }; - - - void getVelocity( const ConservativeVariablesPointer& conservativeVariables, - VelocityFieldPointer& velocity ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; - for( int i = 0; i < Dimensions; i++ ) - { - Pointers::SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), - ( *conservativeVariables->getMomentum() )[ i ] ); - evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); - } - } - - void getPressure( const ConservativeVariablesPointer& conservativeVariables, - const RealType& gamma, - MeshFunctionPointer& pressure ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; - Pointers::SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), - conservativeVariables->getEnergy(), - conservativeVariables->getMomentum(), - gamma ); - evaluator.evaluate( pressure, pressureGetter ); - } - -}; - -} //namespace TNL diff --git a/src/Examples/inviscid-flow/run-euler b/src/Examples/inviscid-flow/run-euler deleted file mode 100644 index 9ebf9cbb5..000000000 --- a/src/Examples/inviscid-flow/run-euler +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -tnl-grid-setup --dimensions 2 \ - --origin-x 0.0 \ - --origin-y 0.0 \ - --proportions-x 1.0 \ - --proportions-y 1.0 \ - --size-x 100 \ - --size-y 100 - -tnl-init --test-function sin-wave \ - --output-file init.tnl -tnl-euler-2d --initial-condition riemann-problem \ - --discontinuity-placement-0 0.3 \ - --discontinuity-placement-1 0.3 \ - --discontinuity-placement-2 0.3 \ - --time-discretisation explicit \ - --boundary-conditions-type neumann \ - --boundary-conditions-constant 0 \ - --discrete-solver euler \ - --time-step 0.0001 \ - --snapshot-period 0.01 \ - --final-time 1.0 - -tnl-view --mesh mesh.tnl --input-files *tnl -- GitLab From 4215d3b058aaf5a9200fa8dc4cec2c7cccc1bab2 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 21 Nov 2018 22:38:04 +0100 Subject: [PATCH 08/28] added AUSM+ differential operator --- .../Navier-Stokes/AUSM+/AUSMPlus.h | 167 ++++++ .../Navier-Stokes/AUSM+/AUSMPlusContinuity.h | 401 ++++++++++++++ .../Navier-Stokes/AUSM+/AUSMPlusEnergy.h | 511 ++++++++++++++++++ .../AUSM+/AUSMPlusMomentumBase.h | 195 +++++++ .../Navier-Stokes/AUSM+/AUSMPlusMomentumX.h | 398 ++++++++++++++ .../Navier-Stokes/AUSM+/AUSMPlusMomentumY.h | 371 +++++++++++++ .../Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h | 316 +++++++++++ src/Examples/flows/navierStokes.h | 4 + 8 files changed, 2363 insertions(+) create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h create mode 100644 src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h new file mode 100644 index 000000000..185641032 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h @@ -0,0 +1,167 @@ +/*************************************************************************** + AUSMPlus.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "AUSMPlusContinuity.h" +#include "AUSMPlusEnergy.h" +#include "AUSMPlusMomentumX.h" +#include "AUSMPlusMomentumY.h" +#include "AUSMPlusMomentumZ.h" + +#include "Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = NullOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlus +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + + typedef AUSMPlusContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef AUSMPlusMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef AUSMPlusMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef AUSMPlusMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef AUSMPlusEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + AUSMPlus() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h new file mode 100644 index 000000000..16558addf --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h @@ -0,0 +1,401 @@ +/*************************************************************************** + AUSMPlusContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "AUSMPlusContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType DensityFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + const RealType& MachSplitingPlus = 0; + const RealType& MachSplitingMinus = 0; + const RealType& MachBorderPlus = 0; + const RealType& MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity + MachBorderMinus * RightDensity ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + -hyInverse * ( + this->DensityFlux( u[ north ], u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) + - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->DensityFlux( u[ west ] , u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + -hyInverse * ( + this->DensityFlux( u[ north ] , u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) + - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + ) + -hzInverse * ( + this->DensityFlux( u[ up ] , u[ center ], velocity_z_up , velocity_z_center, pressure_up , pressure_center ) + - this->DensityFlux( u[ center ], u[ down ] , velocity_z_center, velocity_z_down , pressure_center, pressure_down ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h new file mode 100644 index 000000000..b5b828754 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h @@ -0,0 +1,511 @@ +/*************************************************************************** + AUSMPlusEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + AUSMPlusEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "AUSMPlusEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + RealType EnergyFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure, + const RealType& LeftEnergy, + const RealType& RightEnergy ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + const RealType& MachSplitingPlus = 0; + const RealType& MachSplitingMinus = 0; + const RealType& MachBorderPlus = 0; + const RealType& MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * ( LeftEnergy + LeftPressure) + MachBorderMinus * ( RightEnergy + RightPressure ) ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->DensityFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->DensityFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->DensityFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->DensityFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + -hyInverse * ( + this->DensityFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->DensityFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->DensityFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->DensityFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + -hyInverse * ( + this->DensityFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->DensityFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + ) + -hyInverse * ( + this->DensityFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ], u[ center ] ) + - this->DensityFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h new file mode 100644 index 000000000..4cdea9886 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h @@ -0,0 +1,195 @@ +/*************************************************************************** + AUSMPlusMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + RealType MainMomentumFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + const RealType& MachSplitingPlus = 0; + const RealType& MachSplitingMinus = 0; + const RealType& MachBorderPlus = 0; + const RealType& MachBorderMinus = 0; + const RealType& PressureSplitingPlus = 0; + const RealType& PressureSplitingMinus = 0; + const RealType& PressureBorder = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + PressureSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + PressureSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) * (2.0 - LeftMachNumber ) + + 3.0 / 16.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + PressureSplitingPlus = 1.0; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + PressureSplitingMinus = 1.0; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber + 1.0 ) * ( RightMachNumber + 1.0 ) * (2.0 - RightMachNumber ) + + 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + PressureSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + PressureBorder = PressureSplitingPlus * LeftPressure + PressureSplitingMinus * RightPressure; + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity * LeftVelocity + MachBorderMinus * RightDensity * RightVelocity ) + PressureBorder; + } + + RealType OtherMomentumFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftOtherVelocity, + const RealType& RightOtherVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + const RealType& MachSplitingPlus = 0; + const RealType& MachSplitingMinus = 0; + const RealType& MachBorderPlus = 0; + const RealType& MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity * LeftOtherVelocity + MachBorderMinus * RightDensity * RightOtherVelocity ); + } + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType dynamicalViscosity; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h new file mode 100644 index 000000000..df4f2f2cb --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h @@ -0,0 +1,398 @@ +/*************************************************************************** + AUSMPlusMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + -hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + -hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + -hzInverse * ( + this->OtherMomentumFlux( density_down , density_center, velocity_x_down , velocity_x_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->OtherMomentumFlux( density_center, density_up , velocity_x_center, velocity_x_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h new file mode 100644 index 000000000..a47301043 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h @@ -0,0 +1,371 @@ +/*************************************************************************** + AUSMPlusMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + -hyInverse * ( + this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + -hyInverse * ( + this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) + ) + -hzInverse * ( + this->OtherMomentumFlux( density_down , density_center, velocity_y_down , velocity_y_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->OtherMomentumFlux( density_center, density_up , velocity_y_center, velocity_y_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h new file mode 100644 index 000000000..2ae5d4a71 --- /dev/null +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h @@ -0,0 +1,316 @@ +/*************************************************************************** + AUSMPlusMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_z_west , velocity_z_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_z_center, velocity_z_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + -hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_z_south , velocity_z_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + -hzInverse * ( + this->MainMomentumFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->MainMomentumFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/flows/navierStokes.h b/src/Examples/flows/navierStokes.h index 9ce79a054..338d37f15 100644 --- a/src/Examples/flows/navierStokes.h +++ b/src/Examples/flows/navierStokes.h @@ -8,6 +8,7 @@ #include "DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h" #include "DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h" #include "DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h" +#include "DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" @@ -48,6 +49,7 @@ template< typename ConfigTag >class navierStokesConfig config.addEntryEnum< String >( "Lax-Friedrichs" ); config.addEntryEnum< String >( "Steger-Warming" ); config.addEntryEnum< String >( "VanLeer" ); + config.addEntryEnum< String >( "AUSMPlus" ); config.addEntry< String >( "operator-right-hand-side", "Choose equation type.", "Euler"); config.addEntryEnum< String >( "Euler" ); config.addEntryEnum< String >( "Navier-Stokes" ); @@ -100,6 +102,8 @@ class navierStokesSetter typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; else if( differentialOperatorType == "VanLeer" ) typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + else if( differentialOperatorType == "AUSMPlus" ) + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; /**** * Resolve the template arguments of your solver here. -- GitLab From 66a72280e34547869b40e4c227e0d50fbeac6c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Wed, 28 Nov 2018 22:42:23 +0100 Subject: [PATCH 09/28] added boundary conditions for model of boiler --- .../BoundaryConditionsBoilerModel.h | 159 +++ .../CompressibleConservativeVariables.h | 147 +++ .../DensityBoundaryConditionBoilerModel.h | 580 +++++++++++ .../EnergyBoundaryConditionBoilerModel.h | 928 ++++++++++++++++++ .../MomentumXBoundaryConditionBoilerModel.h | 841 ++++++++++++++++ .../MomentumYBoundaryConditionBoilerModel.h | 836 ++++++++++++++++ .../MomentumZBoundaryConditionBoilerModel.h | 820 ++++++++++++++++ .../Cavity/EnergyBoundaryConditionCavity.h | 8 +- src/Examples/flows/navierStokes.h | 9 + src/Examples/flows/navierStokesProblem.h | 1 + 10 files changed, 4325 insertions(+), 4 deletions(-) create mode 100644 src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h create mode 100644 src/Examples/flows/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h create mode 100644 src/Examples/flows/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h create mode 100644 src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h create mode 100644 src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h create mode 100644 src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h create mode 100644 src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h new file mode 100644 index 000000000..727f919db --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h @@ -0,0 +1,159 @@ +#include + +#include "DensityBoundaryConditionBoilerModel.h" +#include "MomentumXBoundaryConditionBoilerModel.h" +#include "MomentumYBoundaryConditionBoilerModel.h" +#include "MomentumZBoundaryConditionBoilerModel.h" +#include "EnergyBoundaryConditionBoilerModel.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsBoilerModel +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "vertical-angle", "Vertical angle of throttle in degrees", 0 ); + config.addEntry< double >( prefix + "horizontal-angle", "Horizontal angle of throttle in degrees", 45 ); + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + setZAngle(parameters.getParameter< double >( prefix + "vertical-angle" ) * M_PI / 180.0 ); + setXYAngle(parameters.getParameter< double >( prefix + "horizontal-angle" ) * M_PI / 180.0 ); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setZAngle(const RealType zAngle) + { + this->densityBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumXBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumYBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumZBoundaryConditionsPointer->setZAngle(zAngle); + this->energyBoundaryConditionsPointer->setZAngle(zAngle); + } + + void setXYAngle(const RealType xYAngle) + { + this->densityBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumXBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumYBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumZBoundaryConditionsPointer->setXYAngle(xYAngle); + this->energyBoundaryConditionsPointer->setXYAngle(xYAngle); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h b/src/Examples/flows/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h new file mode 100644 index 000000000..01e820686 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h @@ -0,0 +1,147 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + MeshFunctionPointer& getDensity() + { + return this->density; + } + + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /*MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TN diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..67199e114 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h @@ -0,0 +1,580 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().y() < 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + // if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..a4ba5f448 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h @@ -0,0 +1,928 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + + + this->cavitySpeed + * + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ +const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; +// if for chimney exit + } + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) +// &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..e70c2ddda --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -0,0 +1,841 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..dff49ea9e --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h @@ -0,0 +1,836 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..395693f60 --- /dev/null +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -0,0 +1,820 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( + ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h index 6cdbd6a87..ca5d85442 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h @@ -520,18 +520,18 @@ class EnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshInd + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - ( this->cavitySpeed + ( this->cavitySpeed/* * ( entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) ) - / ( entity.getMesh().getDimensions().x() / 2 ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ ) * - ( this->cavitySpeed + ( this->cavitySpeed/* * ( entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) ) - / ( entity.getMesh().getDimensions().x() / 2 ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ ) + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] diff --git a/src/Examples/flows/navierStokes.h b/src/Examples/flows/navierStokes.h index 338d37f15..c7941819c 100644 --- a/src/Examples/flows/navierStokes.h +++ b/src/Examples/flows/navierStokes.h @@ -15,6 +15,7 @@ #include "RiemannProblemInitialCondition.h" #include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" #include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" #include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" #include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" #include "DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h" @@ -42,6 +43,7 @@ template< typename ConfigTag >class navierStokesConfig config.addDelimiter( "Inviscid flow settings:" ); config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); config.addEntryEnum< String >( "cavity" ); config.addEntryEnum< String >( "dirichlet" ); config.addEntryEnum< String >( "neumann" ); @@ -127,6 +129,13 @@ class navierStokesSetter SolverStarter solverStarter; return solverStarter.template run< Problem >( parameters ); } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } typedef Functions::MeshFunction< MeshType > MeshFunction; if( boundaryConditionsType == "dirichlet" ) { diff --git a/src/Examples/flows/navierStokesProblem.h b/src/Examples/flows/navierStokesProblem.h index 999431fb2..8b73a9762 100644 --- a/src/Examples/flows/navierStokesProblem.h +++ b/src/Examples/flows/navierStokesProblem.h @@ -85,6 +85,7 @@ class navierStokesProblem: const RealType& tau, DofVectorPointer& _u, DofVectorPointer& _fu ); + void applyBoundaryConditions( const RealType& time, DofVectorPointer& dofs ); -- GitLab From 54c34731dc9781fabfd9a13b69ae76e8198089b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Sun, 9 Dec 2018 00:40:08 +0100 Subject: [PATCH 10/28] added choice for diff. operator mended AUSM+ diff. operator --- .../MomentumXBoundaryConditionBoilerModel.h | 6 +- .../MomentumYBoundaryConditionBoilerModel.h | 6 +- .../MomentumZBoundaryConditionBoilerModel.h | 2 +- .../Navier-Stokes/AUSM+/AUSMPlus.h | 1 + .../Navier-Stokes/AUSM+/AUSMPlusContinuity.h | 24 +- .../Navier-Stokes/AUSM+/AUSMPlusEnergy.h | 48 +-- .../AUSM+/AUSMPlusMomentumBase.h | 34 +- .../Navier-Stokes/AUSM+/AUSMPlusMomentumX.h | 12 +- .../Navier-Stokes/AUSM+/AUSMPlusMomentumY.h | 10 +- .../Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h | 6 +- .../Lax-Friedrichs/LaxFridrichs.h | 1 + .../Steger-Warming/StegerWarming.h | 1 + .../Steger-Warming/StegerWarmingContinuity.h | 4 +- .../Navier-Stokes/VanLeer/VanLeer.h | 1 + .../NavierStokesOperatorRightHandSide.h | 2 + .../nullOperatorRightHandSide.h | 2 + src/Examples/flows/navierStokes.h | 397 +++++++++++++++--- 17 files changed, 426 insertions(+), 131 deletions(-) diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h index e70c2ddda..8b76be28f 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -209,7 +209,7 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, this->zAngle = zAngle; } - void setXYAngle(const RealType zAngle) + void setXYAngle(const RealType xYAngle) { this->xYAngle = xYAngle; } @@ -398,7 +398,7 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, this->zAngle = zAngle; } - void setXYAngle(const RealType zAngle) + void setXYAngle(const RealType xYAngle) { this->xYAngle = xYAngle; } @@ -811,7 +811,7 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, this->zAngle = zAngle; } - void setXYAngle(const RealType zAngle) + void setXYAngle(const RealType xYAngle) { this->xYAngle = xYAngle; } diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h index dff49ea9e..b048251b5 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h @@ -209,7 +209,7 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, this->zAngle = zAngle; } - void setXYAngle(const RealType zAngle) + void setXYAngle(const RealType xYAngle) { this->xYAngle = xYAngle; } @@ -393,7 +393,7 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, this->zAngle = zAngle; } - void setXYAngle(const RealType zAngle) + void setXYAngle(const RealType xYAngle) { this->xYAngle = xYAngle; } @@ -806,7 +806,7 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, this->zAngle = zAngle; } - void setXYAngle(const RealType zAngle) + void setXYAngle(const RealType xYAngle) { this->xYAngle = xYAngle; } diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h index 395693f60..c9cddd82b 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -673,7 +673,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().z() == 0 ) { if( - ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h index 185641032..9ff576407 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h @@ -75,6 +75,7 @@ class AUSMPlus const Config::ParameterContainer& parameters, const String& prefix = "" ) { + std::cout << "AUSMPlus" << std::endl; this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h index 16558addf..2d92e9dc8 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h @@ -79,17 +79,17 @@ class AUSMPlusContinuityBase const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; - const RealType& MachSplitingPlus = 0; - const RealType& MachSplitingMinus = 0; - const RealType& MachBorderPlus = 0; - const RealType& MachBorderMinus = 0; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; if ( LeftMachNumber <= -1.0 ) { MachSplitingPlus = 0; } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -102,7 +102,7 @@ class AUSMPlusContinuityBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -185,7 +185,7 @@ class AUSMPlusContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Operat const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; - return -hxInverse * ( + return hxInverse * ( this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) @@ -267,11 +267,11 @@ class AUSMPlusContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operat const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; - return -hxInverse * ( + return hxInverse * ( this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) - -hyInverse * ( + + hyInverse * ( this->DensityFlux( u[ north ], u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) ) @@ -362,15 +362,15 @@ class AUSMPlusContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Operat const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - return -hxInverse * ( + return hxInverse * ( this->DensityFlux( u[ west ] , u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) - -hyInverse * ( + + hyInverse * ( this->DensityFlux( u[ north ] , u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) ) - -hzInverse * ( + + hzInverse * ( this->DensityFlux( u[ up ] , u[ center ], velocity_z_up , velocity_z_center, pressure_up , pressure_center ) - this->DensityFlux( u[ center ], u[ down ] , velocity_z_center, velocity_z_down , pressure_center, pressure_down ) ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h index b5b828754..9ee809762 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h @@ -97,17 +97,17 @@ class AUSMPlusEnergyBase const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; - const RealType& MachSplitingPlus = 0; - const RealType& MachSplitingMinus = 0; - const RealType& MachBorderPlus = 0; - const RealType& MachBorderMinus = 0; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; if ( LeftMachNumber <= -1.0 ) { MachSplitingPlus = 0; } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -120,7 +120,7 @@ class AUSMPlusEnergyBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -211,9 +211,9 @@ class AUSMPlusEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRi const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - return -hxInverse * ( - this->DensityFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) - - this->DensityFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) + this->rightHandSide(u, entity, time); @@ -319,13 +319,13 @@ class AUSMPlusEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRi const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - return -hxInverse * ( - this->DensityFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) - - this->DensityFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) - -hyInverse * ( - this->DensityFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) - - this->DensityFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + + hyInverse * ( + this->EnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->EnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) + this->rightHandSide(u, entity, time); @@ -474,17 +474,17 @@ class AUSMPlusEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRi const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - return -hxInverse * ( - this->DensityFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) - - this->DensityFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) - -hyInverse * ( - this->DensityFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) - - this->DensityFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + + hyInverse * ( + this->EnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->EnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) - -hyInverse * ( - this->DensityFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ], u[ center ] ) - - this->DensityFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) + + hyInverse * ( + this->EnergyFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ], u[ center ] ) + - this->EnergyFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h index 4cdea9886..d2c345833 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h @@ -78,13 +78,13 @@ class AUSMPlusMomentumBase const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; - const RealType& MachSplitingPlus = 0; - const RealType& MachSplitingMinus = 0; - const RealType& MachBorderPlus = 0; - const RealType& MachBorderMinus = 0; - const RealType& PressureSplitingPlus = 0; - const RealType& PressureSplitingMinus = 0; - const RealType& PressureBorder = 0; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + RealType PressureSplitingPlus = 0; + RealType PressureSplitingMinus = 0; + RealType PressureBorder = 0; if ( LeftMachNumber <= -1.0 ) { MachSplitingPlus = 0; @@ -92,7 +92,7 @@ class AUSMPlusMomentumBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); PressureSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) * (2.0 - LeftMachNumber ) + 3.0 / 16.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); @@ -109,10 +109,10 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); - PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber + 1.0 ) * ( RightMachNumber + 1.0 ) * (2.0 - RightMachNumber ) - + 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) * (2.0 + RightMachNumber ) + - 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else { @@ -139,17 +139,17 @@ class AUSMPlusMomentumBase const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; - const RealType& MachSplitingPlus = 0; - const RealType& MachSplitingMinus = 0; - const RealType& MachBorderPlus = 0; - const RealType& MachBorderMinus = 0; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; if ( LeftMachNumber <= -1.0 ) { MachSplitingPlus = 0; } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -162,7 +162,7 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h index df4f2f2cb..1468cf891 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h @@ -88,7 +88,7 @@ class AUSMPlusMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Operato const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; - return -hxInverse * ( + return hxInverse * ( this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) @@ -202,11 +202,11 @@ class AUSMPlusMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operato const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - return -hxInverse * ( + return hxInverse * ( this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) - -hyInverse * ( + + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) ) @@ -359,15 +359,15 @@ class AUSMPlusMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - return -hxInverse * ( + return hxInverse * ( this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) - -hyInverse * ( + + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) ) - -hzInverse * ( + + hzInverse * ( this->OtherMomentumFlux( density_down , density_center, velocity_x_down , velocity_x_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) - this->OtherMomentumFlux( density_center, density_up , velocity_x_center, velocity_x_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h index a47301043..d1a8d4304 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h @@ -177,11 +177,11 @@ class AUSMPlusMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operato const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - return -hxInverse * ( + return hxInverse * ( this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) - -hyInverse * ( + + hyInverse * ( this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) @@ -332,15 +332,15 @@ class AUSMPlusMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - return -hxInverse * ( + return hxInverse * ( this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) - -hyInverse * ( + + hyInverse * ( this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) - -hzInverse * ( + + hzInverse * ( this->OtherMomentumFlux( density_down , density_center, velocity_y_down , velocity_y_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) - this->OtherMomentumFlux( density_center, density_up , velocity_y_center, velocity_y_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h index 2ae5d4a71..fcc6183f2 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h @@ -276,15 +276,15 @@ class AUSMPlusMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - return -hxInverse * ( + return hxInverse * ( this->OtherMomentumFlux( density_west , density_center, velocity_z_west , velocity_z_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) - this->OtherMomentumFlux( density_center, density_east , velocity_z_center, velocity_z_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) - -hyInverse * ( + + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_z_south , velocity_z_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) ) - -hzInverse * ( + + hzInverse * ( this->MainMomentumFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) - this->MainMomentumFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h index 411f41d6f..116831f0e 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h @@ -76,6 +76,7 @@ class LaxFridrichs const Config::ParameterContainer& parameters, const String& prefix = "" ) { + std::cout << "Lax-Friedrich" << std::endl; this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h index 0f36447ef..3f1c70d3c 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h @@ -75,6 +75,7 @@ class StegerWarming const Config::ParameterContainer& parameters, const String& prefix = "" ) { + std::cout << "Steger-Warming"<< std::endl; this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h index e42c8d592..5fbef7be6 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h @@ -229,8 +229,8 @@ class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, O const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); //rho - const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); const IndexType& center = entity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h index 97414370f..db39578d0 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h @@ -75,6 +75,7 @@ class VanLeer const Config::ParameterContainer& parameters, const String& prefix = "" ) { + std::cout << "VanLeer" << std::endl; this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h index fdfb7ed8a..b41a9e6a9 100644 --- a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h @@ -66,6 +66,7 @@ class NavierStokesOperatorRightHandSide const Config::ParameterContainer& parameters, const String& prefix = "" ) { + std::cout << "N-S" << std::endl; this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); this->momentumXOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); this->momentumYOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); @@ -76,6 +77,7 @@ class NavierStokesOperatorRightHandSide void setVelocity( const VectorFieldPointer& velocity ) { + std::cout << "N-S" << std::endl; this->continuityOperatorRightHandSidePointer->setVelocity( velocity ); this->momentumXOperatorRightHandSidePointer->setVelocity( velocity ); this->momentumYOperatorRightHandSidePointer->setVelocity( velocity ); diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h index 00faf9881..85b8581f2 100644 --- a/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h @@ -66,6 +66,7 @@ class NullOperatorRightHandSide const Config::ParameterContainer& parameters, const String& prefix = "" ) { + std::cout << "null" << std::endl; this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); this->momentumXOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); this->momentumYOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); @@ -76,6 +77,7 @@ class NullOperatorRightHandSide void setVelocity( const VectorFieldPointer& velocity ) { + std::cout << "null" << std::endl; this->continuityOperatorRightHandSidePointer->setVelocity( velocity ); this->momentumXOperatorRightHandSidePointer->setVelocity( velocity ); this->momentumYOperatorRightHandSidePointer->setVelocity( velocity ); diff --git a/src/Examples/flows/navierStokes.h b/src/Examples/flows/navierStokes.h index c7941819c..4a2a86d9a 100644 --- a/src/Examples/flows/navierStokes.h +++ b/src/Examples/flows/navierStokes.h @@ -62,7 +62,8 @@ template< typename ConfigTag >class navierStokesConfig typedef Meshes::Grid< 3 > Mesh; LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); RiemannProblemInitialCondition< Mesh >::configSetup( config ); - + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); /**** * Add definition of your solver command line arguments. */ @@ -88,69 +89,355 @@ class navierStokesSetter static bool run( const Config::ParameterContainer & parameters ) { enum { Dimension = MeshType::getMeshDimension() }; - typedef NullOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; - typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; typedef flowsRhs< MeshType, Real > RightHandSide; typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; String operatorRightHandSideType = parameters.getParameter< String >( "operator-right-hand-side"); if( operatorRightHandSideType == "Euler" ) + { typedef NullOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; - else if( operatorRightHandSideType == "Navier-Stokes" ) - typedef NavierStokesOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; - String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); - if( differentialOperatorType == "Lax-Friedrichs" ) - typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; - else if( differentialOperatorType == "Steger-Warming" ) - typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; - else if( differentialOperatorType == "VanLeer" ) - typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; - else if( differentialOperatorType == "AUSMPlus" ) - typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; - - /**** - * Resolve the template arguments of your solver here. - * The following code is for the Dirichlet and the Neumann boundary conditions. - * Both can be constant or defined as descrete values of Vector. - */ - - typedef Functions::Analytic::Constant< Dimension, Real > Constant; - String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); - if( boundaryConditionsType == "cavity" ) + String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); + if( differentialOperatorType == "Lax-Friedrichs" ) { - typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; - typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } } - if( boundaryConditionsType == "boiler" ) - { - typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; - typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "boiler-model" ) + if( differentialOperatorType == "Steger-Warming" ) { - typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; - typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - typedef Functions::MeshFunction< MeshType > MeshFunction; - if( boundaryConditionsType == "dirichlet" ) - { - typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; - typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } - if( boundaryConditionsType == "neumann" ) + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "VanLeer" ) + { + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "AUSMPlus" ) + { + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + } + if( operatorRightHandSideType == "Navier-Stokes" ) { - typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; - typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; - SolverStarter solverStarter; - return solverStarter.template run< Problem >( parameters ); - } + typedef NavierStokesOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); + if( differentialOperatorType == "Lax-Friedrichs" ) + { + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "Steger-Warming" ) + { + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "VanLeer" ) + { + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "AUSMPlus" ) + { + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + } return true;} -- GitLab From 358619277d4f7d22e4aa6e710665639efd6b7df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Thu, 6 Dec 2018 14:19:59 +0100 Subject: [PATCH 11/28] Added missing __cuda_callable__ flags to reduce the amount of compiler warnings --- .../Boiler/CompressibleConservativeVariables.h | 13 +++++++++++-- .../BoilerModel/CompressibleConservativeVariables.h | 13 +++++++++++-- .../Cavity/CompressibleConservativeVariables.h | 13 +++++++++++-- .../flows/CompressibleConservativeVariables.h | 13 +++++++++++-- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h b/src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h index 01e820686..b66f4d5c5 100644 --- a/src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h +++ b/src/Examples/flows/BoundaryConditions/Boiler/CompressibleConservativeVariables.h @@ -71,11 +71,13 @@ class CompressibleConservativeVariables this->energy->getDofs( meshPointer ); } + __cuda_callable__ MeshFunctionPointer& getDensity() { return this->density; } + __cuda_callable__ const MeshFunctionPointer& getDensity() const { return this->density; @@ -86,11 +88,13 @@ class CompressibleConservativeVariables this->density = density; } + __cuda_callable__ MomentumFieldPointer& getMomentum() { return this->momentum; } + __cuda_callable__ const MomentumFieldPointer& getMomentum() const { return this->momentum; @@ -101,11 +105,14 @@ class CompressibleConservativeVariables this->momentum = momentum; } - /*MeshFunctionPointer& getPressure() + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() { return this->pressure; } + __cuda_callable__ const MeshFunctionPointer& getPressure() const { return this->pressure; @@ -116,11 +123,13 @@ class CompressibleConservativeVariables this->pressure = pressure; }*/ + __cuda_callable__ MeshFunctionPointer& getEnergy() { return this->energy; } + __cuda_callable__ const MeshFunctionPointer& getEnergy() const { return this->energy; @@ -144,4 +153,4 @@ class CompressibleConservativeVariables }; -} // namespace TN +} // namespace TNL diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h b/src/Examples/flows/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h index 01e820686..b66f4d5c5 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h @@ -71,11 +71,13 @@ class CompressibleConservativeVariables this->energy->getDofs( meshPointer ); } + __cuda_callable__ MeshFunctionPointer& getDensity() { return this->density; } + __cuda_callable__ const MeshFunctionPointer& getDensity() const { return this->density; @@ -86,11 +88,13 @@ class CompressibleConservativeVariables this->density = density; } + __cuda_callable__ MomentumFieldPointer& getMomentum() { return this->momentum; } + __cuda_callable__ const MomentumFieldPointer& getMomentum() const { return this->momentum; @@ -101,11 +105,14 @@ class CompressibleConservativeVariables this->momentum = momentum; } - /*MeshFunctionPointer& getPressure() + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() { return this->pressure; } + __cuda_callable__ const MeshFunctionPointer& getPressure() const { return this->pressure; @@ -116,11 +123,13 @@ class CompressibleConservativeVariables this->pressure = pressure; }*/ + __cuda_callable__ MeshFunctionPointer& getEnergy() { return this->energy; } + __cuda_callable__ const MeshFunctionPointer& getEnergy() const { return this->energy; @@ -144,4 +153,4 @@ class CompressibleConservativeVariables }; -} // namespace TN +} // namespace TNL diff --git a/src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h b/src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h index 01e820686..b66f4d5c5 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/CompressibleConservativeVariables.h @@ -71,11 +71,13 @@ class CompressibleConservativeVariables this->energy->getDofs( meshPointer ); } + __cuda_callable__ MeshFunctionPointer& getDensity() { return this->density; } + __cuda_callable__ const MeshFunctionPointer& getDensity() const { return this->density; @@ -86,11 +88,13 @@ class CompressibleConservativeVariables this->density = density; } + __cuda_callable__ MomentumFieldPointer& getMomentum() { return this->momentum; } + __cuda_callable__ const MomentumFieldPointer& getMomentum() const { return this->momentum; @@ -101,11 +105,14 @@ class CompressibleConservativeVariables this->momentum = momentum; } - /*MeshFunctionPointer& getPressure() + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() { return this->pressure; } + __cuda_callable__ const MeshFunctionPointer& getPressure() const { return this->pressure; @@ -116,11 +123,13 @@ class CompressibleConservativeVariables this->pressure = pressure; }*/ + __cuda_callable__ MeshFunctionPointer& getEnergy() { return this->energy; } + __cuda_callable__ const MeshFunctionPointer& getEnergy() const { return this->energy; @@ -144,4 +153,4 @@ class CompressibleConservativeVariables }; -} // namespace TN +} // namespace TNL diff --git a/src/Examples/flows/CompressibleConservativeVariables.h b/src/Examples/flows/CompressibleConservativeVariables.h index 01e820686..b66f4d5c5 100644 --- a/src/Examples/flows/CompressibleConservativeVariables.h +++ b/src/Examples/flows/CompressibleConservativeVariables.h @@ -71,11 +71,13 @@ class CompressibleConservativeVariables this->energy->getDofs( meshPointer ); } + __cuda_callable__ MeshFunctionPointer& getDensity() { return this->density; } + __cuda_callable__ const MeshFunctionPointer& getDensity() const { return this->density; @@ -86,11 +88,13 @@ class CompressibleConservativeVariables this->density = density; } + __cuda_callable__ MomentumFieldPointer& getMomentum() { return this->momentum; } + __cuda_callable__ const MomentumFieldPointer& getMomentum() const { return this->momentum; @@ -101,11 +105,14 @@ class CompressibleConservativeVariables this->momentum = momentum; } - /*MeshFunctionPointer& getPressure() + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() { return this->pressure; } + __cuda_callable__ const MeshFunctionPointer& getPressure() const { return this->pressure; @@ -116,11 +123,13 @@ class CompressibleConservativeVariables this->pressure = pressure; }*/ + __cuda_callable__ MeshFunctionPointer& getEnergy() { return this->energy; } + __cuda_callable__ const MeshFunctionPointer& getEnergy() const { return this->energy; @@ -144,4 +153,4 @@ class CompressibleConservativeVariables }; -} // namespace TN +} // namespace TNL -- GitLab From 29a11cb4ca56a64a306f3020bee5b29d8ec34342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Mon, 10 Dec 2018 23:59:12 +0100 Subject: [PATCH 12/28] found and resolved problem with 3D riemann initial condition setter --- .../Navier-Stokes/AUSM+/AUSMPlusEnergy.h | 2 +- .../Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h | 2 +- .../Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h | 10 +++++----- .../Navier-Stokes/VanLeer/VanLeerEnergy.h | 10 +++++----- src/Examples/flows/RiemannProblemInitialCondition.h | 6 +----- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h index 9ee809762..5914d28bc 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h @@ -482,7 +482,7 @@ class AUSMPlusEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRi this->EnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) - this->EnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) - + hyInverse * ( + + hzInverse * ( this->EnergyFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ], u[ center ] ) - this->EnergyFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h index 116831f0e..34484a086 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h @@ -76,7 +76,7 @@ class LaxFridrichs const Config::ParameterContainer& parameters, const String& prefix = "" ) { - std::cout << "Lax-Friedrich" << std::endl; + std::cout << "Lax-Friedrichs" << std::endl; this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h index 042222d27..5205f5ba9 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h @@ -519,11 +519,11 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Opera - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) + -hzInverse * ( + this->positiveEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_z_down , velocity_x_down , velocity_y_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_z_up , velocity_x_up , velocity_y_up , pressure_up ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h index 59cff3c66..87ebdd26d 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h @@ -551,11 +551,11 @@ class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRig - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) ) - -hyInverse * ( - this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - - this->positiveEnergyFlux( density_down , velocity_y_down , velocity_x_down , velocity_z_down , pressure_down ) - - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) - + this->negativeEnergyFlux( density_up , velocity_y_up , velocity_x_up , velocity_z_up , pressure_up ) + -hzInverse * ( + this->positiveEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_z_down , velocity_x_down , velocity_y_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_z_up , velocity_x_up , velocity_y_up , pressure_up ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/flows/RiemannProblemInitialCondition.h b/src/Examples/flows/RiemannProblemInitialCondition.h index 0c343589b..ff66ff8b7 100644 --- a/src/Examples/flows/RiemannProblemInitialCondition.h +++ b/src/Examples/flows/RiemannProblemInitialCondition.h @@ -919,7 +919,6 @@ class RiemannProblemInitialCondition this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); this->SEDMomentum = SEDVelocity * SEDDensity; - } if(initial == prefix + "1D_2") predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, @@ -1258,9 +1257,6 @@ class RiemannProblemInitialCondition this->SEDPressure = preSEDPressure; this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); this->SEDMomentum = SEDVelocity * SEDDensity; - - std::cout << this->SEDEnergy; - std::cout << this->SWDEnergy; } @@ -1291,7 +1287,7 @@ class RiemannProblemInitialCondition break; case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); break; - case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 3 ], 2 ))); + case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 2 ], 2 ))); break; // druhou mocninu ps8t jako sou4in } return energy; -- GitLab From e5d13a30960fd22b718e5f68a2f69b2c414340ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Sun, 24 Feb 2019 12:33:51 +0100 Subject: [PATCH 13/28] Fixes after rebase --- src/Examples/flows/CMakeLists.txt | 3 +-- src/Examples/flows/navierStokes.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Examples/flows/CMakeLists.txt b/src/Examples/flows/CMakeLists.txt index 041f2c15d..f26fc6d34 100644 --- a/src/Examples/flows/CMakeLists.txt +++ b/src/Examples/flows/CMakeLists.txt @@ -9,10 +9,9 @@ set( tnl_flow_SOURCES IF( BUILD_CUDA ) CUDA_ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cu) - target_link_libraries (tnl-navier-stokes tnl ${CUSPARSE_LIBRARY} ) + target_link_libraries (tnl-navier-stokes ${CUSPARSE_LIBRARY} ) ELSE( BUILD_CUDA ) ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cpp) - target_link_libraries (tnl-navier-stokes tnl ) ENDIF( BUILD_CUDA ) diff --git a/src/Examples/flows/navierStokes.h b/src/Examples/flows/navierStokes.h index 4a2a86d9a..7d34bfc22 100644 --- a/src/Examples/flows/navierStokes.h +++ b/src/Examples/flows/navierStokes.h @@ -1,4 +1,3 @@ -#include #include #include #include -- GitLab From 12123fd156771c5efdc99214394b18ba62a82dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Sun, 10 Mar 2019 21:14:02 +0100 Subject: [PATCH 14/28] separed solvers, mended errors in N-S right hand sides --- src/Examples/flows/CMakeLists.txt | 91 ++++++++- src/Examples/flows/CMakeLists_separate.txt | 101 ++++++++++ src/Examples/flows/CMakeLists_together.txt | 26 +++ .../Steger-Warming/StegerWarmingContinuity.h | 4 +- .../Steger-Warming/StegerWarmingEnergy.h | 2 +- .../Steger-Warming/StegerWarmingMomentumZ.h | 2 +- ...vierStokesMomentumXOperatorRightHandSide.h | 16 +- ...vierStokesMomentumYOperatorRightHandSide.h | 12 +- ...vierStokesMomentumZOperatorRightHandSide.h | 16 +- src/Examples/flows/flowsRhs.h | 4 +- src/Examples/flows/navierStokesAUSMPlus.cpp | 1 + src/Examples/flows/navierStokesAUSMPlus.cu | 1 + src/Examples/flows/navierStokesAUSMPlus.h | 184 ++++++++++++++++++ .../flows/navierStokesLaxFriedrichs.cpp | 1 + .../flows/navierStokesLaxFriedrichs.cu | 1 + .../flows/navierStokesLaxFriedrichs.h | 184 ++++++++++++++++++ .../flows/navierStokesStegerWarming.cpp | 1 + .../flows/navierStokesStegerWarming.cu | 1 + .../flows/navierStokesStegerWarming.h | 184 ++++++++++++++++++ src/Examples/flows/navierStokesVanLeer.cpp | 1 + src/Examples/flows/navierStokesVanLeer.cu | 1 + src/Examples/flows/navierStokesVanLeer.h | 184 ++++++++++++++++++ .../flows/run-navier-stokes-AUSM-plus | 39 ++++ .../flows/run-navier-stokes-Lax-Friedrichs | 39 ++++ .../flows/run-navier-stokes-Steger-Warming | 39 ++++ src/Examples/flows/run-navier-stokes-Van-Leer | 39 ++++ 26 files changed, 1144 insertions(+), 30 deletions(-) create mode 100644 src/Examples/flows/CMakeLists_separate.txt create mode 100644 src/Examples/flows/CMakeLists_together.txt create mode 100644 src/Examples/flows/navierStokesAUSMPlus.cpp create mode 100644 src/Examples/flows/navierStokesAUSMPlus.cu create mode 100644 src/Examples/flows/navierStokesAUSMPlus.h create mode 100644 src/Examples/flows/navierStokesLaxFriedrichs.cpp create mode 100644 src/Examples/flows/navierStokesLaxFriedrichs.cu create mode 100644 src/Examples/flows/navierStokesLaxFriedrichs.h create mode 100644 src/Examples/flows/navierStokesStegerWarming.cpp create mode 100644 src/Examples/flows/navierStokesStegerWarming.cu create mode 100644 src/Examples/flows/navierStokesStegerWarming.h create mode 100644 src/Examples/flows/navierStokesVanLeer.cpp create mode 100644 src/Examples/flows/navierStokesVanLeer.cu create mode 100644 src/Examples/flows/navierStokesVanLeer.h create mode 100644 src/Examples/flows/run-navier-stokes-AUSM-plus create mode 100644 src/Examples/flows/run-navier-stokes-Lax-Friedrichs create mode 100644 src/Examples/flows/run-navier-stokes-Steger-Warming create mode 100644 src/Examples/flows/run-navier-stokes-Van-Leer diff --git a/src/Examples/flows/CMakeLists.txt b/src/Examples/flows/CMakeLists.txt index f26fc6d34..cd8e6f870 100644 --- a/src/Examples/flows/CMakeLists.txt +++ b/src/Examples/flows/CMakeLists.txt @@ -1,25 +1,100 @@ -#navier-stokes +#navier-stokes-Lax-Friedrichs set( tnl_flow_HEADERS CompressibleConservativeVariables.h ) set( tnl_flow_SOURCES - navierStokes.cpp - navierStokes.cu ) + navierStokesLaxFriedrichs.cpp + navierStokesLaxFriedrichs.cu ) IF( BUILD_CUDA ) - CUDA_ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cu) - target_link_libraries (tnl-navier-stokes ${CUSPARSE_LIBRARY} ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cu) + target_link_libraries (tnl-navier-stokes-Lax-Friedrichs ${CUSPARSE_LIBRARY} ) ELSE( BUILD_CUDA ) - ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cpp) + ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cpp) ENDIF( BUILD_CUDA ) -INSTALL( TARGETS tnl-navier-stokes +INSTALL( TARGETS tnl-navier-stokes-Lax-Friedrichs RUNTIME DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) -INSTALL( FILES run-navier-stokes +INSTALL( FILES run-navier-stokes-Lax-Friedrichs + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Steger-Warming + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesStegerWarming.cpp + navierStokesStegerWarming.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cu) + target_link_libraries (tnl-navier-stokes-Steger-Warming ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Steger-Warming + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Steger-Warming + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Van-Leer + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesVanLeer.cpp + navierStokesVanLeer.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cu) + target_link_libraries (tnl-navier-stokes-Van-Leer ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Van-Leer + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Van-Leer + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-AUSM-plus + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesAUSMPlus.cpp + navierStokesAUSMPlus.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cu) + target_link_libraries (tnl-navier-stokes-AUSM-plus ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-AUSM-plus + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-AUSM-plus ${tnl_flow_SOURCES} DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) diff --git a/src/Examples/flows/CMakeLists_separate.txt b/src/Examples/flows/CMakeLists_separate.txt new file mode 100644 index 000000000..cd8e6f870 --- /dev/null +++ b/src/Examples/flows/CMakeLists_separate.txt @@ -0,0 +1,101 @@ +#navier-stokes-Lax-Friedrichs + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesLaxFriedrichs.cpp + navierStokesLaxFriedrichs.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cu) + target_link_libraries (tnl-navier-stokes-Lax-Friedrichs ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Lax-Friedrichs + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Lax-Friedrichs + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Steger-Warming + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesStegerWarming.cpp + navierStokesStegerWarming.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cu) + target_link_libraries (tnl-navier-stokes-Steger-Warming ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Steger-Warming + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Steger-Warming + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Van-Leer + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesVanLeer.cpp + navierStokesVanLeer.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cu) + target_link_libraries (tnl-navier-stokes-Van-Leer ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Van-Leer + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Van-Leer + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-AUSM-plus + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesAUSMPlus.cpp + navierStokesAUSMPlus.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cu) + target_link_libraries (tnl-navier-stokes-AUSM-plus ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-AUSM-plus + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-AUSM-plus + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/flows/CMakeLists_together.txt b/src/Examples/flows/CMakeLists_together.txt new file mode 100644 index 000000000..f26fc6d34 --- /dev/null +++ b/src/Examples/flows/CMakeLists_together.txt @@ -0,0 +1,26 @@ +#navier-stokes + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokes.cpp + navierStokes.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cu) + target_link_libraries (tnl-navier-stokes ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h index 5fbef7be6..a27d3e139 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h @@ -357,12 +357,12 @@ class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, O - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) ) - -hyInverse * ( +/* -hyInverse * ( this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) - ) + )*/ -hzInverse * ( this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h index 5205f5ba9..2f8f7696a 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h @@ -518,7 +518,7 @@ class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Opera - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) - ) + ) -hzInverse * ( this->positiveEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) - this->positiveEnergyFlux( density_down , velocity_z_down , velocity_x_down , velocity_y_down , pressure_down ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h index eab31d9f1..135352d2f 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h @@ -236,7 +236,7 @@ class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Ope const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; - return -hxInverse * ( + return 0-hxInverse * ( this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumXOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumXOperatorRightHandSide.h index ba1accaf4..6dd2373ea 100644 --- a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumXOperatorRightHandSide.h +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumXOperatorRightHandSide.h @@ -187,7 +187,7 @@ class NavierStokesMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, Mes + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest ) * hxInverse * hyInverse / 4 + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south - ) * hxInverse * hyInverse + ) * hySquareInverse ) * this->dynamicalViscosity; } @@ -279,6 +279,10 @@ class NavierStokesMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, Mesh const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; @@ -321,17 +325,17 @@ class NavierStokesMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, Mesh - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest ) * hxInverse * hzInverse / 4 ) * this->dynamicalViscosity -// T_21_x +// T_21_y + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest ) * hxInverse * hyInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south ) * hxSquareInverse ) * this->dynamicalViscosity -// T_31_x +// T_31_z + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest ) * hxInverse * hzInverse / 4 - + ( velocity_x_east - 2 * velocity_x_center + velocity_x_west - ) * hxSquareInverse + + ( velocity_x_up - 2 * velocity_x_center + velocity_x_down + ) * hzSquareInverse ) * this->dynamicalViscosity; } diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumYOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumYOperatorRightHandSide.h index b6a0e4467..179b325fa 100644 --- a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumYOperatorRightHandSide.h +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumYOperatorRightHandSide.h @@ -277,6 +277,10 @@ class NavierStokesMomentumYRightHandSide< Meshes::Grid< 3,MeshReal, Device, Mesh const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; @@ -303,8 +307,8 @@ class NavierStokesMomentumYRightHandSide< Meshes::Grid< 3,MeshReal, Device, Mesh // T_12_y ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest ) * hxInverse * hyInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse + + ( velocity_y_east - 2 * velocity_y_center + velocity_y_west + ) * hxSquareInverse ) * this->dynamicalViscosity // 3D T_22_y + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south @@ -317,8 +321,8 @@ class NavierStokesMomentumYRightHandSide< Meshes::Grid< 3,MeshReal, Device, Mesh // T_32_y + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth ) * hyInverse * hzInverse / 4 - + ( velocity_y_north - 2 * velocity_y_center + velocity_y_south - ) * hySquareInverse + + ( velocity_y_up - 2 * velocity_y_center + velocity_y_down + ) * hzSquareInverse ) * this->dynamicalViscosity; } diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumZOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumZOperatorRightHandSide.h index 688101700..47fb42c57 100644 --- a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumZOperatorRightHandSide.h +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesMomentumZOperatorRightHandSide.h @@ -242,6 +242,10 @@ class NavierStokesMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, Mesh const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; @@ -253,18 +257,18 @@ class NavierStokesMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, Mesh const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; return -// T_13_z - ( ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse +// T_13_x + ( ( velocity_z_east - 2 * velocity_z_center + velocity_z_west ) + * hxSquareInverse + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) * hxInverse * hzInverse / 4 ) * this->dynamicalViscosity -// T_23_z +// T_23_y + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) * hyInverse * hzInverse / 4 - + ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) - * hzSquareInverse + + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + * hySquareInverse ) * this->dynamicalViscosity // 3D T_33_z diff --git a/src/Examples/flows/flowsRhs.h b/src/Examples/flows/flowsRhs.h index edea64869..e0b8c7fac 100644 --- a/src/Examples/flows/flowsRhs.h +++ b/src/Examples/flows/flowsRhs.h @@ -24,8 +24,8 @@ template< typename Mesh, typename Real >class flowsRhs Real operator()( const MeshEntity& entity, const Real& time = 0.0 ) const { - typedef typename MeshEntity::MeshType::PointType PointType; - PointType v = entity.getCenter(); +// typedef typename MeshEntity::MeshType::PointType PointType; +// PointType v = entity.getCenter(); return 0.0; } }; diff --git a/src/Examples/flows/navierStokesAUSMPlus.cpp b/src/Examples/flows/navierStokesAUSMPlus.cpp new file mode 100644 index 000000000..461c91191 --- /dev/null +++ b/src/Examples/flows/navierStokesAUSMPlus.cpp @@ -0,0 +1 @@ +#include "navierStokesAUSMPlus.h" diff --git a/src/Examples/flows/navierStokesAUSMPlus.cu b/src/Examples/flows/navierStokesAUSMPlus.cu new file mode 100644 index 000000000..461c91191 --- /dev/null +++ b/src/Examples/flows/navierStokesAUSMPlus.cu @@ -0,0 +1 @@ +#include "navierStokesAUSMPlus.h" diff --git a/src/Examples/flows/navierStokesAUSMPlus.h b/src/Examples/flows/navierStokesAUSMPlus.h new file mode 100644 index 000000000..aff663fdc --- /dev/null +++ b/src/Examples/flows/navierStokesAUSMPlus.h @@ -0,0 +1,184 @@ +//#include +#include +#include +#include +#include +#include +#include "navierStokesProblem.h" +#include "DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h" +#include "DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class navierStokesConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< String >( "operator-right-hand-side", "Choose equation type.", "Euler"); + config.addEntryEnum< String >( "Euler" ); + config.addEntryEnum< String >( "Navier-Stokes" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + AUSMPlus< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class navierStokesSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + String operatorRightHandSideType = parameters.getParameter< String >( "operator-right-hand-side"); + if( operatorRightHandSideType == "Euler" ) + { + typedef NullOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( operatorRightHandSideType == "Navier-Stokes" ) + { + typedef NavierStokesOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< navierStokesSetter, navierStokesConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/flows/navierStokesLaxFriedrichs.cpp b/src/Examples/flows/navierStokesLaxFriedrichs.cpp new file mode 100644 index 000000000..d23adec9c --- /dev/null +++ b/src/Examples/flows/navierStokesLaxFriedrichs.cpp @@ -0,0 +1 @@ +#include "navierStokesLaxFriedrichs.h" diff --git a/src/Examples/flows/navierStokesLaxFriedrichs.cu b/src/Examples/flows/navierStokesLaxFriedrichs.cu new file mode 100644 index 000000000..d23adec9c --- /dev/null +++ b/src/Examples/flows/navierStokesLaxFriedrichs.cu @@ -0,0 +1 @@ +#include "navierStokesLaxFriedrichs.h" diff --git a/src/Examples/flows/navierStokesLaxFriedrichs.h b/src/Examples/flows/navierStokesLaxFriedrichs.h new file mode 100644 index 000000000..8392afc5f --- /dev/null +++ b/src/Examples/flows/navierStokesLaxFriedrichs.h @@ -0,0 +1,184 @@ +//#include +#include +#include +#include +#include +#include +#include "navierStokesProblem.h" +#include "DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h" +#include "DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class navierStokesConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< String >( "operator-right-hand-side", "Choose equation type.", "Euler"); + config.addEntryEnum< String >( "Euler" ); + config.addEntryEnum< String >( "Navier-Stokes" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class navierStokesSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + String operatorRightHandSideType = parameters.getParameter< String >( "operator-right-hand-side"); + if( operatorRightHandSideType == "Euler" ) + { + typedef NullOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( operatorRightHandSideType == "Navier-Stokes" ) + { + typedef NavierStokesOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< navierStokesSetter, navierStokesConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/flows/navierStokesStegerWarming.cpp b/src/Examples/flows/navierStokesStegerWarming.cpp new file mode 100644 index 000000000..bce6dd559 --- /dev/null +++ b/src/Examples/flows/navierStokesStegerWarming.cpp @@ -0,0 +1 @@ +#include "navierStokesStegerWarming.h" diff --git a/src/Examples/flows/navierStokesStegerWarming.cu b/src/Examples/flows/navierStokesStegerWarming.cu new file mode 100644 index 000000000..bce6dd559 --- /dev/null +++ b/src/Examples/flows/navierStokesStegerWarming.cu @@ -0,0 +1 @@ +#include "navierStokesStegerWarming.h" diff --git a/src/Examples/flows/navierStokesStegerWarming.h b/src/Examples/flows/navierStokesStegerWarming.h new file mode 100644 index 000000000..ecd24c5b7 --- /dev/null +++ b/src/Examples/flows/navierStokesStegerWarming.h @@ -0,0 +1,184 @@ +//#include +#include +#include +#include +#include +#include +#include "navierStokesProblem.h" +#include "DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h" +#include "DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class navierStokesConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< String >( "operator-right-hand-side", "Choose equation type.", "Euler"); + config.addEntryEnum< String >( "Euler" ); + config.addEntryEnum< String >( "Navier-Stokes" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + StegerWarming< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class navierStokesSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + String operatorRightHandSideType = parameters.getParameter< String >( "operator-right-hand-side"); + if( operatorRightHandSideType == "Euler" ) + { + typedef NullOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( operatorRightHandSideType == "Navier-Stokes" ) + { + typedef NavierStokesOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< navierStokesSetter, navierStokesConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/flows/navierStokesVanLeer.cpp b/src/Examples/flows/navierStokesVanLeer.cpp new file mode 100644 index 000000000..968b16596 --- /dev/null +++ b/src/Examples/flows/navierStokesVanLeer.cpp @@ -0,0 +1 @@ +#include "navierStokesVanLeer.h" diff --git a/src/Examples/flows/navierStokesVanLeer.cu b/src/Examples/flows/navierStokesVanLeer.cu new file mode 100644 index 000000000..7dffcb059 --- /dev/null +++ b/src/Examples/flows/navierStokesVanLeer.cu @@ -0,0 +1 @@ +#include "navierStokes.h" diff --git a/src/Examples/flows/navierStokesVanLeer.h b/src/Examples/flows/navierStokesVanLeer.h new file mode 100644 index 000000000..2ebe4f3aa --- /dev/null +++ b/src/Examples/flows/navierStokesVanLeer.h @@ -0,0 +1,184 @@ +//#include +#include +#include +#include +#include +#include +#include "navierStokesProblem.h" +#include "DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesOperatorRightHandSide.h" +#include "DifferentialOperatorsRightHandSide/nullRightHandSide/nullOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class navierStokesConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< String >( "operator-right-hand-side", "Choose equation type.", "Euler"); + config.addEntryEnum< String >( "Euler" ); + config.addEntryEnum< String >( "Navier-Stokes" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + VanLeer< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class navierStokesSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + String operatorRightHandSideType = parameters.getParameter< String >( "operator-right-hand-side"); + if( operatorRightHandSideType == "Euler" ) + { + typedef NullOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( operatorRightHandSideType == "Navier-Stokes" ) + { + typedef NavierStokesOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef navierStokesProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< navierStokesSetter, navierStokesConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/flows/run-navier-stokes-AUSM-plus b/src/Examples/flows/run-navier-stokes-AUSM-plus new file mode 100644 index 000000000..faaad26b4 --- /dev/null +++ b/src/Examples/flows/run-navier-stokes-AUSM-plus @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Ausm-Plus + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/flows/run-navier-stokes-Lax-Friedrichs b/src/Examples/flows/run-navier-stokes-Lax-Friedrichs new file mode 100644 index 000000000..5f7bfbdc6 --- /dev/null +++ b/src/Examples/flows/run-navier-stokes-Lax-Friedrichs @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Lax-Friedrichs + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/flows/run-navier-stokes-Steger-Warming b/src/Examples/flows/run-navier-stokes-Steger-Warming new file mode 100644 index 000000000..1c3b5ba65 --- /dev/null +++ b/src/Examples/flows/run-navier-stokes-Steger-Warming @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Steger-Warming + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/flows/run-navier-stokes-Van-Leer b/src/Examples/flows/run-navier-stokes-Van-Leer new file mode 100644 index 000000000..1c3b5ba65 --- /dev/null +++ b/src/Examples/flows/run-navier-stokes-Van-Leer @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Steger-Warming + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl -- GitLab From 7c601df9ef64236946b8d5314ef1c9112e2e11e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Thu, 21 Mar 2019 20:23:32 +0100 Subject: [PATCH 15/28] changes in n-s right hand sides, turned on omp paralelization for tnl-view --- .../DensityBoundaryConditionBoilerModel.h | 4 +- .../EnergyBoundaryConditionBoilerModel.h | 252 +++++++++--------- .../MomentumXBoundaryConditionBoilerModel.h | 113 ++++++-- .../MomentumYBoundaryConditionBoilerModel.h | 119 +++++++-- .../NavierStokesEnergyOperatorRightHandSide.h | 80 +++--- src/Tools/tnl-view.h | 6 +- 6 files changed, 366 insertions(+), 208 deletions(-) diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h index 67199e114..a58f32f7c 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h @@ -270,10 +270,10 @@ class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, M } if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) { - if (entity.getCoordinates().y() < 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + if (entity.getCoordinates().y() < 0.835 * ( entity.getMesh().getDimensions().y() - 1 )) return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; } if( entity.getCoordinates().y() == 0 ) { diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h index a4ba5f448..cd8359d37 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h @@ -282,148 +282,138 @@ class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, Me const IndexType& index = entity.getIndex(); if( entity.getCoordinates().x() == 0 ) { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed - * - this->cavitySpeed - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - * - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - + 0 - ) - );*/ - } + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle energy + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + }; if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - * - this->cavitySpeed * ( -1 ) - + - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - ); - else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - + 0 - ) - );*/ + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle energy + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; } if( entity.getCoordinates().y() == 0 ) { - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) - return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - + 0 - ) - + - this->cavitySpeed - * - this->cavitySpeed - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] - + 0 + if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) ) - );*/ + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; } // The following line is commented to avoid compiler warning //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; - /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] - / ( this->gamma - 1 ) - ) - + 0.5 - * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - + 0 - ) - * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] - + 0 - ) - );*/ + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; } } @@ -850,7 +840,7 @@ const RealType operator()( const MeshFunction& u, } if( entity.getCoordinates().z() == 0 ) { - if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + if( ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) // &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] / ( this->gamma - 1 ) diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h index 8b76be28f..2998a525b 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -273,25 +273,106 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, const IndexType& index = entity.getIndex(); if( entity.getCoordinates().x() == 0 ) { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed - ); - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +//throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + * std::cos( this->zAngle ) + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; } if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) { - if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - this->cavitySpeed * ( -1 ) - ); - else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::cos( this->zAngle ) + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; } if( entity.getCoordinates().y() == 0 ) { diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h index b048251b5..3f409c9ef 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h @@ -273,28 +273,115 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, const IndexType& index = entity.getIndex(); if( entity.getCoordinates().x() == 0 ) { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +//throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( - 1.0 ) + * std::sin( this->zAngle ) + ); + } return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] - );*/ } if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) { - if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - else - return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; - /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] - * ( - (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] - / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] - );*/ +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; } if( entity.getCoordinates().y() == 0 ) +// down throttle { - if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + if( + ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) + ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( this->cavitySpeed @@ -304,7 +391,7 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, // The following line is commented to avoid compiler warning //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ } } diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h index e04861e74..744853d73 100644 --- a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h @@ -217,20 +217,20 @@ class NavierStokesEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIn - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west ) * hxInverse * hyInverse / 4 ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west +// vT_12_x + + ( ( velocity_x_northEast * velocity_y_east - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_west + velocity_x_southWest * velocity_y_west ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west + + ( velocity_y_east * velocity_y_center - velocity_y_center * velocity_y_west + - velocity_y_center * velocity_y_center + velocity_y_west * velocity_y_west ) * hxSquareInverse ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south +// uT_21_y + + ( ( velocity_y_northEast * velocity_x_north - velocity_y_southEast * velocity_x_south + - velocity_y_northWest * velocity_x_north + velocity_y_southWest * velocity_x_south ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - - velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south + + ( velocity_x_north * velocity_x_center - velocity_x_center * velocity_x_south + - velocity_x_center * velocity_x_center + velocity_x_south * velocity_x_south ) * hySquareInverse ) * this->dynamicalViscosity // 2D vT_22_y @@ -381,28 +381,28 @@ class NavierStokesEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIn - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west ) * hxInverse * hzInverse / 4 ) * this->dynamicalViscosity -// vT_21_x - + ( ( velocity_y_northEast * velocity_y_east - velocity_y_southEast * velocity_y_east - - velocity_y_northWest * velocity_y_west + velocity_y_southWest * velocity_y_west +// vT_12_x + + ( ( velocity_x_northEast * velocity_y_east - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_west + velocity_x_southWest * velocity_y_west ) * hxInverse * hyInverse / 4 - + ( velocity_x_east * velocity_y_center - velocity_x_center * velocity_y_west - - velocity_x_center * velocity_y_center + velocity_x_west * velocity_y_west + + ( velocity_y_east * velocity_y_center - velocity_y_center * velocity_y_west + - velocity_y_center * velocity_y_center + velocity_y_west * velocity_y_west ) * hxSquareInverse ) * this->dynamicalViscosity -// wT_31_x - + ( ( velocity_z_upEast * velocity_z_east - velocity_z_downEast * velocity_z_east - - velocity_z_upWest * velocity_z_west + velocity_z_downWest * velocity_z_west +// wT_13_x + + ( ( velocity_x_upEast * velocity_z_east - velocity_x_downEast * velocity_z_east + - velocity_x_upWest * velocity_z_west + velocity_x_downWest * velocity_z_west ) * hxInverse * hzInverse / 4 - + ( velocity_x_east * velocity_z_center - velocity_x_center * velocity_z_west - - velocity_x_center * velocity_z_center + velocity_x_west * velocity_z_west + + ( velocity_z_east * velocity_z_center - velocity_z_center * velocity_z_west + - velocity_z_center * velocity_z_center + velocity_z_west * velocity_z_west ) * hxSquareInverse ) * this->dynamicalViscosity -// uT_12_y - + ( ( velocity_x_northEast * velocity_x_north - velocity_x_southEast * velocity_x_south - - velocity_x_northWest * velocity_x_north + velocity_x_southWest * velocity_x_south +// uT_21_y + + ( ( velocity_y_northEast * velocity_x_north - velocity_y_southEast * velocity_x_south + - velocity_y_northWest * velocity_x_north + velocity_y_southWest * velocity_x_south ) * hxInverse * hyInverse / 4 - + ( velocity_y_north * velocity_x_center - velocity_y_center * velocity_x_south - + velocity_y_center * velocity_x_center + velocity_y_south * velocity_x_south + + ( velocity_x_north * velocity_x_center - velocity_x_center * velocity_x_south + + velocity_x_center * velocity_x_center + velocity_x_south * velocity_x_south ) * hySquareInverse ) * this->dynamicalViscosity // 3D vT_22_y @@ -416,28 +416,28 @@ class NavierStokesEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIn - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south ) * hyInverse * hzInverse / 4 ) * this->dynamicalViscosity -// wT_32_y - + ( ( velocity_z_upNorth * velocity_z_north - velocity_z_downNorth * velocity_y_north - - velocity_z_upSouth * velocity_z_south + velocity_z_downSouth * velocity_z_south +// wT_23_y + + ( ( velocity_y_upNorth * velocity_z_north - velocity_y_downNorth * velocity_y_north + - velocity_y_upSouth * velocity_z_south + velocity_y_downSouth * velocity_z_south ) * hyInverse * hzInverse / 4 - + ( velocity_y_north * velocity_z_center - velocity_y_center * velocity_z_south - - velocity_y_center * velocity_z_center + velocity_y_south * velocity_z_south + + ( velocity_z_north * velocity_z_center - velocity_z_center * velocity_z_south + - velocity_z_center * velocity_z_center + velocity_z_south * velocity_z_south ) * hySquareInverse ) * this->dynamicalViscosity -// uT_13_z - + ( ( velocity_z_up * velocity_x_center - velocity_z_center * velocity_x_center - - velocity_z_center * velocity_x_down + velocity_z_down * velocity_x_down +// uT_31_z + + ( ( velocity_x_up * velocity_x_center - velocity_x_center * velocity_x_center + - velocity_x_center * velocity_x_down + velocity_x_down * velocity_x_down ) * hzSquareInverse - + ( velocity_x_upEast * velocity_x_up - velocity_x_downEast * velocity_x_down - - velocity_x_upWest * velocity_x_up + velocity_x_downWest * velocity_x_down + + ( velocity_z_upEast * velocity_x_up - velocity_z_downEast * velocity_x_down + - velocity_z_upWest * velocity_x_up + velocity_z_downWest * velocity_x_down ) * hxInverse * hzInverse / 4 ) * this->dynamicalViscosity -// T_23_z - + ( ( velocity_y_upNorth * velocity_y_up - velocity_y_downNorth * velocity_y_down - - velocity_y_upSouth * velocity_y_up + velocity_y_downSouth * velocity_y_down +// T_32_z + + ( ( velocity_z_upNorth * velocity_y_up - velocity_z_downNorth * velocity_y_down + - velocity_z_upSouth * velocity_y_up + velocity_z_downSouth * velocity_y_down ) * hyInverse * hzInverse / 4 - + ( velocity_z_up * velocity_y_center - velocity_z_center * velocity_y_down - - velocity_z_center * velocity_y_center + velocity_z_down * velocity_y_down + + ( velocity_x_up * velocity_y_center - velocity_x_center * velocity_y_down + - velocity_x_center * velocity_y_center + velocity_x_down * velocity_y_down ) * hzSquareInverse ) * this->dynamicalViscosity // 3D T_33_z diff --git a/src/Tools/tnl-view.h b/src/Tools/tnl-view.h index cd7cd93b9..64462cd79 100644 --- a/src/Tools/tnl-view.h +++ b/src/Tools/tnl-view.h @@ -417,9 +417,9 @@ struct FilesProcessor bool checkOutputFile = parameters. getParameter< bool >( "check-output-file" ); std::vector< String > inputFiles = parameters. getParameter< std::vector< String > >( "input-files" ); bool error( false ); - //#ifdef HAVE_OPENMP - //#pragma omp parallel for - //#endif + #ifdef HAVE_OPENMP + #pragma omp parallel for + #endif for( int i = 0; i < (int) inputFiles.size(); i++ ) { if( verbose ) -- GitLab From eb29a2837e75a57427b9ae19a1a27d53c4cbbc67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Fri, 22 Mar 2019 20:41:30 +0100 Subject: [PATCH 16/28] minor foxes in rhs --- .../NavierStokesEnergyOperatorRightHandSide.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h index 744853d73..64fbb2429 100644 --- a/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h +++ b/src/Examples/flows/DifferentialOperatorsRightHandSide/NavierStokesRightHandSide/NavierStokesEnergyOperatorRightHandSide.h @@ -237,8 +237,8 @@ class NavierStokesEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIn + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south ) * hySquareInverse - - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_east - - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_west + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south ) * hxInverse * hyInverse / 4 ) * this->dynamicalViscosity; } -- GitLab From a4bd422afb75980e47e2cf0446009cea2d1c1882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Thu, 28 Mar 2019 11:11:36 +0100 Subject: [PATCH 17/28] boiler model boundary conditions have separate speeds for different throttles and possibility of increasing speed --- .../Boiler/BoundaryConditionsBoiler.h | 16 +++ .../BoundaryConditionsBoilerModel.h | 43 ++++++- .../EnergyBoundaryConditionBoilerModel.h | 114 ++++++++++++------ .../MomentumXBoundaryConditionBoilerModel.h | 56 ++++++--- .../MomentumYBoundaryConditionBoilerModel.h | 58 ++++++--- .../MomentumZBoundaryConditionBoilerModel.h | 54 ++++++--- .../Cavity/BoundaryConditionsCavity.h | 16 +++ .../Dirichlet/BoundaryConditionsDirichlet.h | 16 +++ .../Neumann/BoundaryConditionsNeumann.h | 16 +++ src/Examples/flows/navierStokes.h | 2 + src/Examples/flows/navierStokesAUSMPlus.h | 2 + .../flows/navierStokesLaxFriedrichs.h | 2 + src/Examples/flows/navierStokesProblem.h | 4 +- src/Examples/flows/navierStokesProblem_impl.h | 4 + .../flows/navierStokesStegerWarming.h | 2 + src/Examples/flows/navierStokesVanLeer.h | 2 + 16 files changed, 310 insertions(+), 97 deletions(-) diff --git a/src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h b/src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h index f61f988da..953199081 100644 --- a/src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h +++ b/src/Examples/flows/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h @@ -99,6 +99,22 @@ class BoundaryConditionsBoiler this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); } + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() { return this->densityBoundaryConditionsPointer; diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h index 727f919db..7c96e79ff 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h @@ -115,10 +115,45 @@ class BoundaryConditionsBoilerModel void setSpeed(const RealType cavitySpeed) { - this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); - this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + RealType horizontalThrottleSpeed = 0; + if(time <= finalTime) + if( time != 0 || finalTime != 0 ) + horizontalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) / ( time / finalTime ); + else + horizontalThrottleSpeed = 0; + else + horizontalThrottleSpeed = finalSpeed; + this->momentumXBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->momentumYBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->momentumZBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->energyBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + RealType verticalThrottleSpeed = 0; + if(time <= finalTime) + if( time != 0 || finalTime != 0 ) + verticalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) / ( time / finalTime ); + else + verticalThrottleSpeed = 0; + else + verticalThrottleSpeed = finalSpeed; + this->momentumXBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->momentumYBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->momentumZBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->energyBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); } DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h index cd8359d37..d0475576b 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h @@ -208,9 +208,14 @@ class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, Me this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -226,7 +231,8 @@ class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, Me private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; @@ -328,9 +334,9 @@ class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, Me + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * - this->cavitySpeed + this->horizontalThrottleSpeed ); } return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; @@ -383,14 +389,26 @@ class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, Me + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * - this->cavitySpeed + this->horizontalThrottleSpeed ); } // if for chimney exit if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + if( (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] != 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * ( ( (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + ) + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + ); + else return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; } if( entity.getCoordinates().y() == 0 ) @@ -404,9 +422,9 @@ class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, Me + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( - this->cavitySpeed + this->verticalThrottleSpeed * - this->cavitySpeed + this->verticalThrottleSpeed ); return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; } @@ -491,9 +509,14 @@ class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, Me this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -509,7 +532,8 @@ class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, Me private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; @@ -610,9 +634,9 @@ const RealType operator()( const MeshFunction& u, + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * - this->cavitySpeed + this->horizontalThrottleSpeed ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] @@ -621,9 +645,9 @@ const RealType operator()( const MeshFunction& u, + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * - this->cavitySpeed + this->horizontalThrottleSpeed ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; } @@ -678,9 +702,9 @@ const RealType operator()( const MeshFunction& u, + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * - this->cavitySpeed + this->horizontalThrottleSpeed ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] @@ -689,16 +713,30 @@ const RealType operator()( const MeshFunction& u, + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * - this->cavitySpeed + this->horizontalThrottleSpeed ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; // if for chimney exit } if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) - return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + if( (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] != 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * ( ( (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 2 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 2 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + ) + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + ); + else return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; } if( entity.getCoordinates().y() == 0 ) @@ -750,9 +788,9 @@ const RealType operator()( const MeshFunction& u, + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * - this->cavitySpeed + this->horizontalThrottleSpeed ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] @@ -761,9 +799,9 @@ const RealType operator()( const MeshFunction& u, + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * - this->cavitySpeed + this->horizontalThrottleSpeed ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; @@ -819,9 +857,9 @@ const RealType operator()( const MeshFunction& u, + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * - this->cavitySpeed + this->horizontalThrottleSpeed ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] @@ -830,9 +868,9 @@ const RealType operator()( const MeshFunction& u, + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * - this->cavitySpeed + this->horizontalThrottleSpeed ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; } @@ -848,9 +886,9 @@ const RealType operator()( const MeshFunction& u, + 0.5 * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->verticalThrottleSpeed * - this->cavitySpeed + this->verticalThrottleSpeed ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; } @@ -878,9 +916,14 @@ const RealType operator()( const MeshFunction& u, this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -896,7 +939,8 @@ const RealType operator()( const MeshFunction& u, private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h index 2998a525b..65648c389 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -199,9 +199,14 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -217,7 +222,8 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; @@ -315,7 +321,7 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, { return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::cos( this->zAngle ) ); } @@ -365,7 +371,7 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, { return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::cos( this->zAngle ) ); } @@ -469,9 +475,14 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -487,7 +498,8 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; @@ -584,14 +596,14 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::cos( this->xYAngle ) * std::cos( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::sin( this->xYAngle ) * std::cos( this->zAngle ) ); @@ -644,14 +656,14 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->xYAngle ) * std::cos( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::cos( this->xYAngle ) * std::cos( this->zAngle ) ); @@ -707,14 +719,14 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::cos( this->xYAngle ) * std::cos( this->zAngle ) ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->xYAngle ) * std::cos( this->zAngle ) ); @@ -767,14 +779,14 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::sin( this->xYAngle ) * std::cos( this->zAngle ) ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::cos( this->xYAngle ) * std::cos( this->zAngle ) ); @@ -882,9 +894,14 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -900,7 +917,8 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h index 3f409c9ef..e8aa33e88 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h @@ -199,9 +199,14 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -217,7 +222,8 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; @@ -315,7 +321,7 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, { return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( - this->cavitySpeed * ( - 1.0 ) + this->horizontalThrottleSpeed * ( - 1.0 ) * std::sin( this->zAngle ) ); } @@ -365,7 +371,7 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, { return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); } @@ -384,7 +390,7 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( - this->cavitySpeed + this->verticalThrottleSpeed ); else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; } @@ -470,9 +476,14 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -488,7 +499,8 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; @@ -585,14 +597,14 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::sin( this->xYAngle ) * std::cos( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::cos( this->xYAngle ) * std::cos( this->zAngle ) ); @@ -645,14 +657,14 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::cos( this->xYAngle ) * std::cos( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->xYAngle ) * std::cos( this->zAngle ) ); @@ -708,14 +720,14 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::sin( this->xYAngle ) * std::cos( this->zAngle ) ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::cos( this->xYAngle ) * std::cos( this->zAngle ) ); @@ -768,14 +780,14 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::cos( this->xYAngle ) * std::cos( this->zAngle ) ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->xYAngle ) * std::cos( this->zAngle ) ); @@ -883,9 +895,14 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -901,7 +918,8 @@ class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h index c9cddd82b..625b74585 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -199,9 +199,14 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -217,7 +222,8 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; @@ -364,9 +370,14 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -383,7 +394,8 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; @@ -480,13 +492,13 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; @@ -538,13 +550,13 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; @@ -599,13 +611,13 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::sin( this->zAngle ) ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->horizontalThrottleSpeed * std::sin( this->zAngle ) ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; @@ -657,13 +669,13 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed * ( -1.0 ) + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; @@ -679,7 +691,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->cavitySpeed + this->verticalThrottleSpeed ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; } @@ -779,9 +791,14 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, this->pressure = pressure; } - void setCavitySpeed(const RealType cavitySpeed) + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) { - this->cavitySpeed = cavitySpeed; + this->verticalThrottleSpeed = verticalThrottleSpeed; } void setZAngle(const RealType zAngle) @@ -798,7 +815,8 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, private: CompressibleConservativeVariablesPointer compressibleConservativeVariables; RealType timestep; - RealType cavitySpeed; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; RealType gamma; MeshFunctionPointer pressure; RealType zAngle; diff --git a/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h b/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h index bbae2d3e9..9c3c0b099 100644 --- a/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h +++ b/src/Examples/flows/BoundaryConditions/Cavity/BoundaryConditionsCavity.h @@ -99,6 +99,22 @@ class BoundaryConditionsCavity this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); } + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() { return this->densityBoundaryConditionsPointer; diff --git a/src/Examples/flows/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h b/src/Examples/flows/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h index 095f9ef3f..930183476 100644 --- a/src/Examples/flows/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h +++ b/src/Examples/flows/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h @@ -74,6 +74,22 @@ class BoundaryConditionsDirichlet } + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() { return this->densityBoundaryConditionsPointer; diff --git a/src/Examples/flows/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h b/src/Examples/flows/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h index 5d44c091d..ec99b86e7 100644 --- a/src/Examples/flows/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h +++ b/src/Examples/flows/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h @@ -70,6 +70,22 @@ class BoundaryConditionsNeumann } + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() { return this->densityBoundaryConditionsPointer; diff --git a/src/Examples/flows/navierStokes.h b/src/Examples/flows/navierStokes.h index 7d34bfc22..e9b09ac31 100644 --- a/src/Examples/flows/navierStokes.h +++ b/src/Examples/flows/navierStokes.h @@ -57,6 +57,8 @@ template< typename ConfigTag >class navierStokesConfig config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); typedef Meshes::Grid< 3 > Mesh; LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); diff --git a/src/Examples/flows/navierStokesAUSMPlus.h b/src/Examples/flows/navierStokesAUSMPlus.h index aff663fdc..a99e07894 100644 --- a/src/Examples/flows/navierStokesAUSMPlus.h +++ b/src/Examples/flows/navierStokesAUSMPlus.h @@ -50,6 +50,8 @@ template< typename ConfigTag >class navierStokesConfig config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); typedef Meshes::Grid< 3 > Mesh; AUSMPlus< Mesh >::configSetup( config, "inviscid-operators-" ); diff --git a/src/Examples/flows/navierStokesLaxFriedrichs.h b/src/Examples/flows/navierStokesLaxFriedrichs.h index 8392afc5f..ec2207f1b 100644 --- a/src/Examples/flows/navierStokesLaxFriedrichs.h +++ b/src/Examples/flows/navierStokesLaxFriedrichs.h @@ -50,6 +50,8 @@ template< typename ConfigTag >class navierStokesConfig config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); typedef Meshes::Grid< 3 > Mesh; LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); diff --git a/src/Examples/flows/navierStokesProblem.h b/src/Examples/flows/navierStokesProblem.h index 8b73a9762..14ccdeb82 100644 --- a/src/Examples/flows/navierStokesProblem.h +++ b/src/Examples/flows/navierStokesProblem.h @@ -124,7 +124,9 @@ class navierStokesProblem: RealType gamma; RealType speedIncrement; RealType cavitySpeed; - RealType speedIncrementUntil; + RealType speedIncrementUntil; + RealType finalSpeed; + RealType startSpeed; }; } // namespace TNL diff --git a/src/Examples/flows/navierStokesProblem_impl.h b/src/Examples/flows/navierStokesProblem_impl.h index a27de41a0..48b8ce5cb 100644 --- a/src/Examples/flows/navierStokesProblem_impl.h +++ b/src/Examples/flows/navierStokesProblem_impl.h @@ -78,6 +78,8 @@ setup( const Config::ParameterContainer& parameters, ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) return false; this->gamma = parameters.getParameter< double >( "gamma" ); + this->startSpeed = parameters.getParameter< double >( "start-speed" ); + this->finalSpeed = parameters.getParameter< double >( "final-speed" ); velocity->setMesh( this->getMesh() ); pressure->setMesh( this->getMesh() ); @@ -351,6 +353,8 @@ applyBoundaryConditions( const RealType& time, this->boundaryConditionPointer->setCompressibleConservativeVariables(this->conservativeVariables); this->boundaryConditionPointer->setGamma(this->gamma); this->boundaryConditionPointer->setPressure(this->pressure); + this->boundaryConditionPointer->setVerticalThrottleSpeed( startSpeed, finalSpeed, time, speedIncrementUntil ); + this->boundaryConditionPointer->setHorizontalThrottleSpeed( startSpeed, finalSpeed, time, speedIncrementUntil ); /**** * Bind DOFs */ diff --git a/src/Examples/flows/navierStokesStegerWarming.h b/src/Examples/flows/navierStokesStegerWarming.h index ecd24c5b7..230f89ed1 100644 --- a/src/Examples/flows/navierStokesStegerWarming.h +++ b/src/Examples/flows/navierStokesStegerWarming.h @@ -50,6 +50,8 @@ template< typename ConfigTag >class navierStokesConfig config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); typedef Meshes::Grid< 3 > Mesh; StegerWarming< Mesh >::configSetup( config, "inviscid-operators-" ); diff --git a/src/Examples/flows/navierStokesVanLeer.h b/src/Examples/flows/navierStokesVanLeer.h index 2ebe4f3aa..379be8d3f 100644 --- a/src/Examples/flows/navierStokesVanLeer.h +++ b/src/Examples/flows/navierStokesVanLeer.h @@ -50,6 +50,8 @@ template< typename ConfigTag >class navierStokesConfig config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); typedef Meshes::Grid< 3 > Mesh; VanLeer< Mesh >::configSetup( config, "inviscid-operators-" ); -- GitLab From 11efe6c0d42ddcb85addd9c497d7fa831eee99ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Thu, 28 Mar 2019 16:01:29 +0100 Subject: [PATCH 18/28] minor adjustments --- .../BoilerModel/BoundaryConditionsBoilerModel.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h index 7c96e79ff..06228f789 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h @@ -125,8 +125,8 @@ class BoundaryConditionsBoilerModel { RealType horizontalThrottleSpeed = 0; if(time <= finalTime) - if( time != 0 || finalTime != 0 ) - horizontalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) / ( time / finalTime ); + if( time != 0 && finalTime != 0 ) + horizontalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) * ( time / finalTime ); else horizontalThrottleSpeed = 0; else @@ -144,8 +144,8 @@ class BoundaryConditionsBoilerModel { RealType verticalThrottleSpeed = 0; if(time <= finalTime) - if( time != 0 || finalTime != 0 ) - verticalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) / ( time / finalTime ); + if( time != 0 && finalTime != 0 ) + verticalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) * ( time / finalTime ); else verticalThrottleSpeed = 0; else -- GitLab From 115b1ccba2dc5e9abcac55d10bcbc49cbe2115ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Fri, 29 Mar 2019 15:32:16 +0100 Subject: [PATCH 19/28] splitted velocities for horizontal and vertical throttles --- src/Examples/flows/navierStokes.h | 3 +++ src/Examples/flows/navierStokesAUSMPlus.h | 3 +++ src/Examples/flows/navierStokesLaxFriedrichs.h | 3 +++ src/Examples/flows/navierStokesProblem.h | 5 ++++- src/Examples/flows/navierStokesProblem_impl.h | 6 +++++- src/Examples/flows/navierStokesStegerWarming.h | 3 +++ src/Examples/flows/navierStokesVanLeer.h | 3 +++ 7 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Examples/flows/navierStokes.h b/src/Examples/flows/navierStokes.h index e9b09ac31..18ca18996 100644 --- a/src/Examples/flows/navierStokes.h +++ b/src/Examples/flows/navierStokes.h @@ -59,6 +59,9 @@ template< typename ConfigTag >class navierStokesConfig config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); typedef Meshes::Grid< 3 > Mesh; LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); diff --git a/src/Examples/flows/navierStokesAUSMPlus.h b/src/Examples/flows/navierStokesAUSMPlus.h index a99e07894..933033541 100644 --- a/src/Examples/flows/navierStokesAUSMPlus.h +++ b/src/Examples/flows/navierStokesAUSMPlus.h @@ -52,6 +52,9 @@ template< typename ConfigTag >class navierStokesConfig config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); typedef Meshes::Grid< 3 > Mesh; AUSMPlus< Mesh >::configSetup( config, "inviscid-operators-" ); diff --git a/src/Examples/flows/navierStokesLaxFriedrichs.h b/src/Examples/flows/navierStokesLaxFriedrichs.h index ec2207f1b..6aabedd7d 100644 --- a/src/Examples/flows/navierStokesLaxFriedrichs.h +++ b/src/Examples/flows/navierStokesLaxFriedrichs.h @@ -52,6 +52,9 @@ template< typename ConfigTag >class navierStokesConfig config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); typedef Meshes::Grid< 3 > Mesh; LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); diff --git a/src/Examples/flows/navierStokesProblem.h b/src/Examples/flows/navierStokesProblem.h index 14ccdeb82..7fed439bf 100644 --- a/src/Examples/flows/navierStokesProblem.h +++ b/src/Examples/flows/navierStokesProblem.h @@ -126,7 +126,10 @@ class navierStokesProblem: RealType cavitySpeed; RealType speedIncrementUntil; RealType finalSpeed; - RealType startSpeed; + RealType startSpeed; + RealType speedIncrementUntilHThrottle; + RealType finalSpeedHThrottle; + RealType startSpeedHThrottle; }; } // namespace TNL diff --git a/src/Examples/flows/navierStokesProblem_impl.h b/src/Examples/flows/navierStokesProblem_impl.h index 48b8ce5cb..503802aee 100644 --- a/src/Examples/flows/navierStokesProblem_impl.h +++ b/src/Examples/flows/navierStokesProblem_impl.h @@ -80,6 +80,10 @@ setup( const Config::ParameterContainer& parameters, this->gamma = parameters.getParameter< double >( "gamma" ); this->startSpeed = parameters.getParameter< double >( "start-speed" ); this->finalSpeed = parameters.getParameter< double >( "final-speed" ); + this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); + this->startSpeedHThrottle = parameters.getParameter< double >( "start-speed-h-throttle" ); + this->finalSpeedHThrottle = parameters.getParameter< double >( "final-speed-h-throttle" ); + this->speedIncrementUntilHThrottle = parameters.getParameter< RealType >( "speed-increment-until-h-throttle" ); velocity->setMesh( this->getMesh() ); pressure->setMesh( this->getMesh() ); @@ -354,7 +358,7 @@ applyBoundaryConditions( const RealType& time, this->boundaryConditionPointer->setGamma(this->gamma); this->boundaryConditionPointer->setPressure(this->pressure); this->boundaryConditionPointer->setVerticalThrottleSpeed( startSpeed, finalSpeed, time, speedIncrementUntil ); - this->boundaryConditionPointer->setHorizontalThrottleSpeed( startSpeed, finalSpeed, time, speedIncrementUntil ); + this->boundaryConditionPointer->setHorizontalThrottleSpeed( startSpeedHThrottle, finalSpeedHThrottle, time, speedIncrementUntilHThrottle ); /**** * Bind DOFs */ diff --git a/src/Examples/flows/navierStokesStegerWarming.h b/src/Examples/flows/navierStokesStegerWarming.h index 230f89ed1..f7a1df06a 100644 --- a/src/Examples/flows/navierStokesStegerWarming.h +++ b/src/Examples/flows/navierStokesStegerWarming.h @@ -52,6 +52,9 @@ template< typename ConfigTag >class navierStokesConfig config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); typedef Meshes::Grid< 3 > Mesh; StegerWarming< Mesh >::configSetup( config, "inviscid-operators-" ); diff --git a/src/Examples/flows/navierStokesVanLeer.h b/src/Examples/flows/navierStokesVanLeer.h index 379be8d3f..ed6c73714 100644 --- a/src/Examples/flows/navierStokesVanLeer.h +++ b/src/Examples/flows/navierStokesVanLeer.h @@ -52,6 +52,9 @@ template< typename ConfigTag >class navierStokesConfig config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); typedef Meshes::Grid< 3 > Mesh; VanLeer< Mesh >::configSetup( config, "inviscid-operators-" ); -- GitLab From 8391172dbcc65b8d6636544fb2857a74af9f57c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Tue, 16 Apr 2019 18:34:53 +0200 Subject: [PATCH 20/28] repairs to make project compilable --- src/Examples/flows/navierStokesProblem_impl.h | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/Examples/flows/navierStokesProblem_impl.h b/src/Examples/flows/navierStokesProblem_impl.h index 503802aee..047379d0f 100644 --- a/src/Examples/flows/navierStokesProblem_impl.h +++ b/src/Examples/flows/navierStokesProblem_impl.h @@ -238,20 +238,24 @@ makeSnapshot( const RealType& time, fileName.setExtension( "tnl" ); fileName.setIndex( step ); fileName.setFileNameBase( "density-" ); - if( ! this->conservativeVariables->getDensity()->save( fileName.getFileName() ) ) - return false; +// if( ! this->conservativeVariables->getDensity()->save( fileName.getFileName() ) ) + this->conservativeVariables->getDensity()->save( fileName.getFileName() ); +// return false; fileName.setFileNameBase( "velocity-" ); - if( ! this->velocity->save( fileName.getFileName() ) ) - return false; +// if( ! this->velocity->save( fileName.getFileName() ) ) + this->velocity->save( fileName.getFileName() ); +// return false; fileName.setFileNameBase( "pressure-" ); - if( ! this->pressure->save( fileName.getFileName() ) ) - return false; +// if( ! this->pressure->save( fileName.getFileName() ) ) + this->pressure->save( fileName.getFileName() ); +// return false; fileName.setFileNameBase( "energy-" ); - if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) - return false; +// if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) + this->conservativeVariables->getEnergy()->save( fileName.getFileName() ); +// return false; return true; } -- GitLab From 9759c6abacd06db6d9af3ce8efa787029ffc5c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Sat, 20 Apr 2019 18:17:38 +0200 Subject: [PATCH 21/28] added Prandtl, PrandtlKolmogorov, KOmega and KEpsilon Solvers. Prandtl not working yet --- src/Examples/CMakeLists.txt | 3 +- src/Examples/turbulent-flows/CMakeLists.txt | 3 + .../Boiler/BoundaryConditionsBoiler.h | 168 ++ .../CompressibleConservativeVariables.h | 156 ++ .../Boiler/DensityBoundaryConditionBoiler.h | 542 +++++ .../Boiler/EnergyBoundaryConditionBoiler.h | 853 ++++++++ .../Boiler/MomentumXBoundaryConditionBoiler.h | 594 ++++++ .../Boiler/MomentumYBoundaryConditionBoiler.h | 588 +++++ .../Boiler/MomentumZBoundaryConditionBoiler.h | 563 +++++ .../TurbulentEnergyBoundaryConditionBoiler.h | 664 ++++++ .../BoundaryConditionsBoilerModel.h | 211 ++ .../CompressibleConservativeVariables.h | 156 ++ .../DensityBoundaryConditionBoilerModel.h | 580 +++++ .../EnergyBoundaryConditionBoilerModel.h | 962 +++++++++ .../MomentumXBoundaryConditionBoilerModel.h | 940 ++++++++ .../MomentumYBoundaryConditionBoilerModel.h | 941 ++++++++ .../MomentumZBoundaryConditionBoilerModel.h | 838 ++++++++ ...bulentEnergyBoundaryConditionBoilerModel.h | 832 ++++++++ .../Cavity/BoundaryConditionsCavity.h | 170 ++ .../CompressibleConservativeVariables.h | 156 ++ .../Cavity/DensityBoundaryConditionCavity.h | 536 +++++ .../Cavity/EnergyBoundaryConditionCavity.h | 672 ++++++ .../Cavity/MomentumXBoundaryConditionCavity.h | 570 +++++ .../Cavity/MomentumYBoundaryConditionCavity.h | 564 +++++ .../Cavity/MomentumZBoundaryConditionCavity.h | 554 +++++ .../TurbulentEnergyBoundaryConditionCavity.h | 568 +++++ .../Dirichlet/BoundaryConditionsDirichlet.h | 141 ++ .../Neumann/BoundaryConditionsNeumann.h | 137 ++ .../one-equation-model/CMakeLists.txt | 101 + .../CMakeLists_separate.txt | 101 + .../CMakeLists_together.txt | 26 + .../CompressibleConservativeVariables.h | 179 ++ .../AUSM+/AUSMPlus.h | 213 ++ .../AUSM+/AUSMPlusContinuity.h | 401 ++++ .../AUSM+/AUSMPlusEnergy.h | 521 +++++ .../AUSM+/AUSMPlusMomentumBase.h | 205 ++ .../AUSM+/AUSMPlusMomentumX.h | 398 ++++ .../AUSM+/AUSMPlusMomentumY.h | 371 ++++ .../AUSM+/AUSMPlusMomentumZ.h | 316 +++ .../AUSM+/AUSMPlusTurbulentEnergy.h | 458 ++++ .../Lax-Friedrichs/LaxFridrichs.h | 214 ++ .../Lax-Friedrichs/LaxFridrichsContinuity.h | 310 +++ .../Lax-Friedrichs/LaxFridrichsEnergy.h | 349 +++ .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 88 + .../Lax-Friedrichs/LaxFridrichsMomentumX.h | 295 +++ .../Lax-Friedrichs/LaxFridrichsMomentumY.h | 280 +++ .../Lax-Friedrichs/LaxFridrichsMomentumZ.h | 251 +++ .../LaxFridrichsTurbulentEnergy.h | 342 +++ .../Steger-Warming/StegerWarming.h | 218 ++ .../Steger-Warming/StegerWarmingContinuity.h | 396 ++++ .../Steger-Warming/StegerWarmingEnergy.h | 560 +++++ .../StegerWarmingMomentumBase.h | 150 ++ .../Steger-Warming/StegerWarmingMomentumX.h | 356 ++++ .../Steger-Warming/StegerWarmingMomentumY.h | 326 +++ .../Steger-Warming/StegerWarmingMomentumZ.h | 282 +++ .../StegerWarmingTurbulentEnergy.h | 452 ++++ .../VanLeer/VanLeer.h | 213 ++ .../VanLeer/VanLeerContinuity.h | 396 ++++ .../VanLeer/VanLeerEnergy.h | 592 +++++ .../VanLeer/VanLeerMomentumBase.h | 145 ++ .../VanLeer/VanLeerMomentumX.h | 410 ++++ .../VanLeer/VanLeerMomentumY.h | 381 ++++ .../VanLeer/VanLeerMomentumZ.h | 322 +++ .../VanLeer/VanLeerTurbulentEnergy.h | 446 ++++ ...olmogorovContinuityOperatorRightHandSide.h | 218 ++ ...dtlKolmogorovEnergyOperatorRightHandSide.h | 687 ++++++ ...mogorovMomentumBaseOperatorRightHandSide.h | 75 + ...KolmogorovMomentumXOperatorRightHandSide.h | 450 ++++ ...KolmogorovMomentumYOperatorRightHandSide.h | 417 ++++ ...KolmogorovMomentumZOperatorRightHandSide.h | 343 +++ .../PrandtlKolmogorovOperatorRightHandSide.h | 160 ++ ...orovTurbulentEnergyOperatorRightHandSide.h | 574 +++++ .../PhysicalVariablesGetter.h | 204 ++ .../RiemannProblemInitialCondition.h | 1663 +++++++++++++++ .../one-equation-model/flowsBuildConfigTag.h | 72 + .../one-equation-model/flowsRhs.h | 35 + .../oneEquationTurbulenceModel.cpp | 1 + .../oneEquationTurbulenceModel.cu | 1 + .../oneEquationTurbulenceModel.h | 276 +++ .../oneEquationTurbulenceModelAUSMPlus.cpp | 1 + .../oneEquationTurbulenceModelAUSMPlus.cu | 1 + .../oneEquationTurbulenceModelAUSMPlus.h | 142 ++ ...neEquationTurbulenceModelLaxFriedrichs.cpp | 1 + ...oneEquationTurbulenceModelLaxFriedrichs.cu | 1 + .../oneEquationTurbulenceModelLaxFriedrichs.h | 142 ++ .../oneEquationTurbulenceModelProblem.h | 145 ++ .../oneEquationTurbulenceModelProblem_impl.h | 538 +++++ ...neEquationTurbulenceModelStegerWarming.cpp | 1 + ...oneEquationTurbulenceModelStegerWarming.cu | 1 + .../oneEquationTurbulenceModelStegerWarming.h | 142 ++ .../oneEquationTurbulenceModelVanLeer.cpp | 1 + .../oneEquationTurbulenceModelVanLeer.cu | 1 + .../oneEquationTurbulenceModelVanLeer.h | 138 ++ .../run-one-equation-turbulence-model | 40 + ...un-one-equation-turbulence-model-AUSM-plus | 39 + ...e-equation-turbulence-model-Lax-Friedrichs | 39 + ...e-equation-turbulence-model-Steger-Warming | 39 + ...run-one-equation-turbulence-model-Van-Leer | 39 + .../two-equation-model/CMakeLists.txt | 2 + .../Boiler/BoundaryConditionsBoiler.h | 190 ++ .../CompressibleConservativeVariables.h | 156 ++ .../Boiler/DensityBoundaryConditionBoiler.h | 542 +++++ .../DisipationBoundaryConditionBoiler.h | 718 +++++++ .../Boiler/EnergyBoundaryConditionBoiler.h | 853 ++++++++ .../Boiler/MomentumXBoundaryConditionBoiler.h | 594 ++++++ .../Boiler/MomentumYBoundaryConditionBoiler.h | 588 +++++ .../Boiler/MomentumZBoundaryConditionBoiler.h | 563 +++++ .../TurbulentEnergyBoundaryConditionBoiler.h | 664 ++++++ .../BoundaryConditionsBoilerModel.h | 237 +++ .../CompressibleConservativeVariables.h | 156 ++ .../DensityBoundaryConditionBoilerModel.h | 580 +++++ .../DisipationBoundaryConditionBoilerModel.h | 892 ++++++++ .../EnergyBoundaryConditionBoilerModel.h | 962 +++++++++ .../MomentumXBoundaryConditionBoilerModel.h | 940 ++++++++ .../MomentumYBoundaryConditionBoilerModel.h | 941 ++++++++ .../MomentumZBoundaryConditionBoilerModel.h | 838 ++++++++ ...bulentEnergyBoundaryConditionBoilerModel.h | 832 ++++++++ .../Cavity/BoundaryConditionsCavity.h | 193 ++ .../CompressibleConservativeVariables.h | 156 ++ .../Cavity/DensityBoundaryConditionCavity.h | 536 +++++ .../DisipationBoundaryConditionCavity.h | 610 ++++++ .../Cavity/EnergyBoundaryConditionCavity.h | 672 ++++++ .../Cavity/MomentumXBoundaryConditionCavity.h | 570 +++++ .../Cavity/MomentumYBoundaryConditionCavity.h | 564 +++++ .../Cavity/MomentumZBoundaryConditionCavity.h | 554 +++++ .../TurbulentEnergyBoundaryConditionCavity.h | 568 +++++ .../Dirichlet/BoundaryConditionsDirichlet.h | 159 ++ .../Neumann/BoundaryConditionsNeumann.h | 155 ++ .../KEPsilon-model/CMakeLists.txt | 101 + .../KEPsilon-model/CMakeLists_separate.txt | 101 + .../KEPsilon-model/CMakeLists_together.txt | 26 + .../CompressibleConservativeVariables.h | 202 ++ .../AUSM+/AUSMPlus.h | 246 +++ .../AUSM+/AUSMPlusContinuity.h | 401 ++++ .../AUSM+/AUSMPlusDisipation.h | 465 ++++ .../AUSM+/AUSMPlusEnergy.h | 521 +++++ .../AUSM+/AUSMPlusMomentumBase.h | 205 ++ .../AUSM+/AUSMPlusMomentumX.h | 398 ++++ .../AUSM+/AUSMPlusMomentumY.h | 371 ++++ .../AUSM+/AUSMPlusMomentumZ.h | 316 +++ .../AUSM+/AUSMPlusTurbulentEnergy.h | 449 ++++ .../Lax-Friedrichs/LaxFridrichs.h | 244 +++ .../Lax-Friedrichs/LaxFridrichsContinuity.h | 310 +++ .../Lax-Friedrichs/LaxFridrichsDisipation.h | 352 +++ .../Lax-Friedrichs/LaxFridrichsEnergy.h | 349 +++ .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 88 + .../Lax-Friedrichs/LaxFridrichsMomentumX.h | 295 +++ .../Lax-Friedrichs/LaxFridrichsMomentumY.h | 280 +++ .../Lax-Friedrichs/LaxFridrichsMomentumZ.h | 251 +++ .../LaxFridrichsTurbulentEnergy.h | 342 +++ .../Steger-Warming/StegerWarming.h | 247 +++ .../Steger-Warming/StegerWarmingContinuity.h | 396 ++++ .../Steger-Warming/StegerWarmingDisipation.h | 458 ++++ .../Steger-Warming/StegerWarmingEnergy.h | 560 +++++ .../StegerWarmingMomentumBase.h | 150 ++ .../Steger-Warming/StegerWarmingMomentumX.h | 356 ++++ .../Steger-Warming/StegerWarmingMomentumY.h | 326 +++ .../Steger-Warming/StegerWarmingMomentumZ.h | 282 +++ .../StegerWarmingTurbulentEnergy.h | 442 ++++ .../VanLeer/VanLeer.h | 246 +++ .../VanLeer/VanLeerContinuity.h | 396 ++++ .../VanLeer/VanLeerDisipation.h | 453 ++++ .../VanLeer/VanLeerEnergy.h | 592 +++++ .../VanLeer/VanLeerMomentumBase.h | 145 ++ .../VanLeer/VanLeerMomentumX.h | 410 ++++ .../VanLeer/VanLeerMomentumY.h | 381 ++++ .../VanLeer/VanLeerMomentumZ.h | 322 +++ .../VanLeer/VanLeerTurbulentEnergy.h | 437 ++++ .../KEpsilonContinuityOperatorRightHandSide.h | 218 ++ .../KEpsilonDisipationOperatorRightHandSide.h | 592 +++++ .../KEpsilonEnergyOperatorRightHandSide.h | 687 ++++++ ...EpsilonMomentumBaseOperatorRightHandSide.h | 75 + .../KEpsilonMomentumXOperatorRightHandSide.h | 450 ++++ .../KEpsilonMomentumYOperatorRightHandSide.h | 417 ++++ .../KEpsilonMomentumZOperatorRightHandSide.h | 343 +++ .../KEpsilonOperatorRightHandSide.h | 169 ++ ...ilonTurbulentEnergyOperatorRightHandSide.h | 528 +++++ .../KEPsilon-model/PhysicalVariablesGetter.h | 243 +++ .../RiemannProblemInitialCondition.h | 1896 +++++++++++++++++ .../KEPsilon-model/flowsBuildConfigTag.h | 72 + .../KEPsilon-model/flowsRhs.h | 35 + .../run-two-equation-turbulence-model | 40 + ...un-two-equation-turbulence-model-AUSM-plus | 39 + ...o-equation-turbulence-model-Lax-Friedrichs | 39 + ...o-equation-turbulence-model-Steger-Warming | 39 + ...run-two-equation-turbulence-model-Van-Leer | 39 + .../twoEquationTurbulenceModel.cpp | 1 + .../twoEquationTurbulenceModel.cu | 1 + .../twoEquationTurbulenceModel.h | 276 +++ .../twoEquationTurbulenceModelAUSMPlus.cpp | 1 + .../twoEquationTurbulenceModelAUSMPlus.cu | 1 + .../twoEquationTurbulenceModelAUSMPlus.h | 145 ++ ...woEquationTurbulenceModelLaxFriedrichs.cpp | 1 + ...twoEquationTurbulenceModelLaxFriedrichs.cu | 1 + .../twoEquationTurbulenceModelLaxFriedrichs.h | 145 ++ .../twoEquationTurbulenceModelProblem.h | 150 ++ .../twoEquationTurbulenceModelProblem_impl.h | 566 +++++ ...woEquationTurbulenceModelStegerWarming.cpp | 1 + ...twoEquationTurbulenceModelStegerWarming.cu | 1 + .../twoEquationTurbulenceModelStegerWarming.h | 145 ++ .../twoEquationTurbulenceModelVanLeer.cpp | 1 + .../twoEquationTurbulenceModelVanLeer.cu | 1 + .../twoEquationTurbulenceModelVanLeer.h | 145 ++ .../Boiler/BoundaryConditionsBoiler.h | 190 ++ .../CompressibleConservativeVariables.h | 156 ++ .../Boiler/DensityBoundaryConditionBoiler.h | 542 +++++ .../DisipationBoundaryConditionBoiler.h | 718 +++++++ .../Boiler/EnergyBoundaryConditionBoiler.h | 853 ++++++++ .../Boiler/MomentumXBoundaryConditionBoiler.h | 594 ++++++ .../Boiler/MomentumYBoundaryConditionBoiler.h | 588 +++++ .../Boiler/MomentumZBoundaryConditionBoiler.h | 563 +++++ .../TurbulentEnergyBoundaryConditionBoiler.h | 664 ++++++ .../BoundaryConditionsBoilerModel.h | 237 +++ .../CompressibleConservativeVariables.h | 156 ++ .../DensityBoundaryConditionBoilerModel.h | 580 +++++ .../DisipationBoundaryConditionBoilerModel.h | 892 ++++++++ .../EnergyBoundaryConditionBoilerModel.h | 962 +++++++++ .../MomentumXBoundaryConditionBoilerModel.h | 940 ++++++++ .../MomentumYBoundaryConditionBoilerModel.h | 941 ++++++++ .../MomentumZBoundaryConditionBoilerModel.h | 838 ++++++++ ...bulentEnergyBoundaryConditionBoilerModel.h | 832 ++++++++ .../Cavity/BoundaryConditionsCavity.h | 193 ++ .../CompressibleConservativeVariables.h | 156 ++ .../Cavity/DensityBoundaryConditionCavity.h | 536 +++++ .../DisipationBoundaryConditionCavity.h | 610 ++++++ .../Cavity/EnergyBoundaryConditionCavity.h | 672 ++++++ .../Cavity/MomentumXBoundaryConditionCavity.h | 570 +++++ .../Cavity/MomentumYBoundaryConditionCavity.h | 564 +++++ .../Cavity/MomentumZBoundaryConditionCavity.h | 554 +++++ .../TurbulentEnergyBoundaryConditionCavity.h | 568 +++++ .../Dirichlet/BoundaryConditionsDirichlet.h | 159 ++ .../Neumann/BoundaryConditionsNeumann.h | 155 ++ .../KOmega-model/CMakeLists.txt | 101 + .../KOmega-model/CMakeLists_separate.txt | 101 + .../KOmega-model/CMakeLists_together.txt | 26 + .../CompressibleConservativeVariables.h | 202 ++ .../AUSM+/AUSMPlus.h | 252 +++ .../AUSM+/AUSMPlusContinuity.h | 401 ++++ .../AUSM+/AUSMPlusDisipation.h | 465 ++++ .../AUSM+/AUSMPlusEnergy.h | 521 +++++ .../AUSM+/AUSMPlusMomentumBase.h | 205 ++ .../AUSM+/AUSMPlusMomentumX.h | 398 ++++ .../AUSM+/AUSMPlusMomentumY.h | 371 ++++ .../AUSM+/AUSMPlusMomentumZ.h | 316 +++ .../AUSM+/AUSMPlusTurbulentEnergy.h | 459 ++++ .../Lax-Friedrichs/LaxFridrichs.h | 250 +++ .../Lax-Friedrichs/LaxFridrichsContinuity.h | 310 +++ .../Lax-Friedrichs/LaxFridrichsDisipation.h | 352 +++ .../Lax-Friedrichs/LaxFridrichsEnergy.h | 349 +++ .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 88 + .../Lax-Friedrichs/LaxFridrichsMomentumX.h | 295 +++ .../Lax-Friedrichs/LaxFridrichsMomentumY.h | 280 +++ .../Lax-Friedrichs/LaxFridrichsMomentumZ.h | 251 +++ .../LaxFridrichsTurbulentEnergy.h | 342 +++ .../Steger-Warming/StegerWarming.h | 253 +++ .../Steger-Warming/StegerWarmingContinuity.h | 396 ++++ .../Steger-Warming/StegerWarmingDisipation.h | 458 ++++ .../Steger-Warming/StegerWarmingEnergy.h | 560 +++++ .../StegerWarmingMomentumBase.h | 150 ++ .../Steger-Warming/StegerWarmingMomentumX.h | 356 ++++ .../Steger-Warming/StegerWarmingMomentumY.h | 326 +++ .../Steger-Warming/StegerWarmingMomentumZ.h | 282 +++ .../StegerWarmingTurbulentEnergy.h | 452 ++++ .../VanLeer/VanLeer.h | 252 +++ .../VanLeer/VanLeerContinuity.h | 396 ++++ .../VanLeer/VanLeerDisipation.h | 453 ++++ .../VanLeer/VanLeerEnergy.h | 592 +++++ .../VanLeer/VanLeerMomentumBase.h | 145 ++ .../VanLeer/VanLeerMomentumX.h | 410 ++++ .../VanLeer/VanLeerMomentumY.h | 381 ++++ .../VanLeer/VanLeerMomentumZ.h | 322 +++ .../VanLeer/VanLeerTurbulentEnergy.h | 447 ++++ .../KOmegaContinuityOperatorRightHandSide.h | 218 ++ .../KOmegaDisipationOperatorRightHandSide.h | 592 +++++ .../KOmegaEnergyOperatorRightHandSide.h | 687 ++++++ .../KOmegaMomentumBaseOperatorRightHandSide.h | 75 + .../KOmegaMomentumXOperatorRightHandSide.h | 450 ++++ .../KOmegaMomentumYOperatorRightHandSide.h | 417 ++++ .../KOmegaMomentumZOperatorRightHandSide.h | 343 +++ .../KOmegaOperatorRightHandSide.h | 169 ++ ...megaTurbulentEnergyOperatorRightHandSide.h | 553 +++++ .../KOmega-model/PhysicalVariablesGetter.h | 243 +++ .../RiemannProblemInitialCondition.h | 1896 +++++++++++++++++ .../KOmega-model/flowsBuildConfigTag.h | 72 + .../KOmega-model/flowsRhs.h | 35 + .../run-two-equation-turbulence-model | 40 + ...un-two-equation-turbulence-model-AUSM-plus | 39 + ...o-equation-turbulence-model-Lax-Friedrichs | 39 + ...o-equation-turbulence-model-Steger-Warming | 39 + ...run-two-equation-turbulence-model-Van-Leer | 39 + .../twoEquationTurbulenceModel.cpp | 1 + .../twoEquationTurbulenceModel.cu | 1 + .../KOmega-model/twoEquationTurbulenceModel.h | 276 +++ .../twoEquationTurbulenceModelAUSMPlus.cpp | 1 + .../twoEquationTurbulenceModelAUSMPlus.cu | 1 + .../twoEquationTurbulenceModelAUSMPlus.h | 145 ++ ...woEquationTurbulenceModelLaxFriedrichs.cpp | 1 + ...twoEquationTurbulenceModelLaxFriedrichs.cu | 1 + .../twoEquationTurbulenceModelLaxFriedrichs.h | 145 ++ .../twoEquationTurbulenceModelProblem.h | 151 ++ .../twoEquationTurbulenceModelProblem_impl.h | 566 +++++ ...woEquationTurbulenceModelStegerWarming.cpp | 1 + ...twoEquationTurbulenceModelStegerWarming.cu | 1 + .../twoEquationTurbulenceModelStegerWarming.h | 146 ++ .../twoEquationTurbulenceModelVanLeer.cpp | 1 + .../twoEquationTurbulenceModelVanLeer.cu | 1 + .../twoEquationTurbulenceModelVanLeer.h | 145 ++ .../Boiler/BoundaryConditionsBoiler.h | 153 ++ .../CompressibleConservativeVariables.h | 156 ++ .../Boiler/DensityBoundaryConditionBoiler.h | 542 +++++ .../Boiler/EnergyBoundaryConditionBoiler.h | 853 ++++++++ .../Boiler/MomentumXBoundaryConditionBoiler.h | 594 ++++++ .../Boiler/MomentumYBoundaryConditionBoiler.h | 588 +++++ .../Boiler/MomentumZBoundaryConditionBoiler.h | 563 +++++ .../BoundaryConditionsBoilerModel.h | 194 ++ .../CompressibleConservativeVariables.h | 156 ++ .../DensityBoundaryConditionBoilerModel.h | 580 +++++ .../EnergyBoundaryConditionBoilerModel.h | 962 +++++++++ .../MomentumXBoundaryConditionBoilerModel.h | 940 ++++++++ .../MomentumYBoundaryConditionBoilerModel.h | 941 ++++++++ .../MomentumZBoundaryConditionBoilerModel.h | 838 ++++++++ .../Cavity/BoundaryConditionsCavity.h | 153 ++ .../CompressibleConservativeVariables.h | 156 ++ .../Cavity/DensityBoundaryConditionCavity.h | 536 +++++ .../Cavity/EnergyBoundaryConditionCavity.h | 672 ++++++ .../Cavity/MomentumXBoundaryConditionCavity.h | 570 +++++ .../Cavity/MomentumYBoundaryConditionCavity.h | 564 +++++ .../Cavity/MomentumZBoundaryConditionCavity.h | 554 +++++ .../Dirichlet/BoundaryConditionsDirichlet.h | 128 ++ .../Neumann/BoundaryConditionsNeumann.h | 124 ++ .../zero-equation-model/CMakeLists.txt | 101 + .../CMakeLists_separate.txt | 101 + .../CMakeLists_together.txt | 26 + .../CompressibleConservativeVariables.h | 156 ++ .../Navier-Stokes/AUSM+/AUSMPlus.h | 185 ++ .../Navier-Stokes/AUSM+/AUSMPlusContinuity.h | 401 ++++ .../Navier-Stokes/AUSM+/AUSMPlusEnergy.h | 516 +++++ .../AUSM+/AUSMPlusMomentumBase.h | 200 ++ .../Navier-Stokes/AUSM+/AUSMPlusMomentumX.h | 398 ++++ .../Navier-Stokes/AUSM+/AUSMPlusMomentumY.h | 371 ++++ .../Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h | 316 +++ .../Lax-Friedrichs/LaxFridrichs.h | 183 ++ .../Lax-Friedrichs/LaxFridrichsContinuity.h | 310 +++ .../Lax-Friedrichs/LaxFridrichsEnergy.h | 344 +++ .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 83 + .../Lax-Friedrichs/LaxFridrichsMomentumX.h | 295 +++ .../Lax-Friedrichs/LaxFridrichsMomentumY.h | 280 +++ .../Lax-Friedrichs/LaxFridrichsMomentumZ.h | 251 +++ .../Steger-Warming/StegerWarming.h | 176 ++ .../Steger-Warming/StegerWarmingContinuity.h | 396 ++++ .../Steger-Warming/StegerWarmingEnergy.h | 555 +++++ .../StegerWarmingMomentumBase.h | 145 ++ .../Steger-Warming/StegerWarmingMomentumX.h | 356 ++++ .../Steger-Warming/StegerWarmingMomentumY.h | 326 +++ .../Steger-Warming/StegerWarmingMomentumZ.h | 282 +++ .../Navier-Stokes/VanLeer/VanLeer.h | 185 ++ .../Navier-Stokes/VanLeer/VanLeerContinuity.h | 396 ++++ .../Navier-Stokes/VanLeer/VanLeerEnergy.h | 587 +++++ .../VanLeer/VanLeerMomentumBase.h | 140 ++ .../Navier-Stokes/VanLeer/VanLeerMomentumX.h | 410 ++++ .../Navier-Stokes/VanLeer/VanLeerMomentumY.h | 381 ++++ .../Navier-Stokes/VanLeer/VanLeerMomentumZ.h | 322 +++ .../PrandtlContinuityOperatorRightHandSide.h | 218 ++ .../PrandtlEnergyOperatorRightHandSide.h | 619 ++++++ ...PrandtlMomentumBaseOperatorRightHandSide.h | 66 + .../PrandtlMomentumXOperatorRightHandSide.h | 419 ++++ .../PrandtlMomentumYOperatorRightHandSide.h | 397 ++++ .../PrandtlMomentumZOperatorRightHandSide.h | 333 +++ .../PrandtlOperatorRightHandSide.h | 130 ++ .../PhysicalVariablesGetter.h | 134 ++ .../RiemannProblemInitialCondition.h | 1413 ++++++++++++ .../zero-equation-model/flowsBuildConfigTag.h | 72 + .../zero-equation-model/flowsRhs.h | 35 + .../run-zero-equation-turbulence-model | 40 + ...n-zero-equation-turbulence-model-AUSM-plus | 39 + ...o-equation-turbulence-model-Lax-Friedrichs | 39 + ...o-equation-turbulence-model-Steger-Warming | 39 + ...un-zero-equation-turbulence-model-Van-Leer | 39 + .../turbulentViscosityGetter.h | 299 +++ .../zeroEquationTurbulenceModel.cpp | 1 + .../zeroEquationTurbulenceModel.cu | 1 + .../zeroEquationTurbulenceModel.h | 276 +++ .../zeroEquationTurbulenceModelAUSMPlus.cpp | 1 + .../zeroEquationTurbulenceModelAUSMPlus.cu | 1 + .../zeroEquationTurbulenceModelAUSMPlus.h | 138 ++ ...roEquationTurbulenceModelLaxFriedrichs.cpp | 1 + ...eroEquationTurbulenceModelLaxFriedrichs.cu | 1 + ...zeroEquationTurbulenceModelLaxFriedrichs.h | 139 ++ .../zeroEquationTurbulenceModelProblem.h | 140 ++ .../zeroEquationTurbulenceModelProblem_impl.h | 507 +++++ ...roEquationTurbulenceModelStegerWarming.cpp | 1 + ...eroEquationTurbulenceModelStegerWarming.cu | 1 + ...zeroEquationTurbulenceModelStegerWarming.h | 138 ++ .../zeroEquationTurbulenceModelVanLeer.cpp | 1 + .../zeroEquationTurbulenceModelVanLeer.cu | 1 + .../zeroEquationTurbulenceModelVanLeer.h | 141 ++ 396 files changed, 130742 insertions(+), 1 deletion(-) create mode 100644 src/Examples/turbulent-flows/CMakeLists.txt create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/CMakeLists.txt create mode 100644 src/Examples/turbulent-flows/one-equation-model/CMakeLists_separate.txt create mode 100644 src/Examples/turbulent-flows/one-equation-model/CMakeLists_together.txt create mode 100644 src/Examples/turbulent-flows/one-equation-model/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlus.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarming.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeer.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerContinuity.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerEnergy.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovContinuityOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovEnergyOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumBaseOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumXOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumYOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumZOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/PhysicalVariablesGetter.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/RiemannProblemInitialCondition.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/flowsBuildConfigTag.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/flowsRhs.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.cpp create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.cu create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.cpp create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.cu create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.cpp create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.cu create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem_impl.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.cpp create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.cu create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.cpp create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.cu create mode 100644 src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h create mode 100644 src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model create mode 100644 src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-AUSM-plus create mode 100644 src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Lax-Friedrichs create mode 100644 src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Steger-Warming create mode 100644 src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Van-Leer create mode 100644 src/Examples/turbulent-flows/two-equation-model/CMakeLists.txt create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists.txt create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists_separate.txt create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists_together.txt create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsDisipation.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingDisipation.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerContinuity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerDisipation.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonContinuityOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonEnergyOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumBaseOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumXOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumYOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumZOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonTurbulentEnergyOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/PhysicalVariablesGetter.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/RiemannProblemInitialCondition.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/flowsBuildConfigTag.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/flowsRhs.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-AUSM-plus create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Lax-Friedrichs create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Steger-Warming create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Van-Leer create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.cpp create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.cu create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.cpp create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.cu create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.cpp create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.cu create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem_impl.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.cpp create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.cu create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.cpp create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.cu create mode 100644 src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists.txt create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists_separate.txt create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists_together.txt create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsDisipation.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingDisipation.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerContinuity.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerDisipation.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaContinuityOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaDisipationOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaEnergyOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumBaseOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumXOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumYOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumZOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaTurbulentEnergyOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/PhysicalVariablesGetter.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/RiemannProblemInitialCondition.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/flowsBuildConfigTag.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/flowsRhs.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-AUSM-plus create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Lax-Friedrichs create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Steger-Warming create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Van-Leer create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.cpp create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.cu create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.cpp create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.cu create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.cpp create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.cu create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.cpp create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.cu create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.h create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.cpp create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.cu create mode 100644 src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/CMakeLists.txt create mode 100644 src/Examples/turbulent-flows/zero-equation-model/CMakeLists_separate.txt create mode 100644 src/Examples/turbulent-flows/zero-equation-model/CMakeLists_together.txt create mode 100644 src/Examples/turbulent-flows/zero-equation-model/CompressibleConservativeVariables.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlContinuityOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlEnergyOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumBaseOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumXOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumYOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumZOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/PhysicalVariablesGetter.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/RiemannProblemInitialCondition.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/flowsBuildConfigTag.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/flowsRhs.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model create mode 100644 src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-AUSM-plus create mode 100644 src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Lax-Friedrichs create mode 100644 src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Steger-Warming create mode 100644 src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Van-Leer create mode 100644 src/Examples/turbulent-flows/zero-equation-model/turbulentViscosityGetter.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.cpp create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.cu create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.cpp create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.cu create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.cpp create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.cu create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.cpp create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.cu create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.h create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.cpp create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.cu create mode 100644 src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.h diff --git a/src/Examples/CMakeLists.txt b/src/Examples/CMakeLists.txt index a132af7bd..b0ed1aa08 100644 --- a/src/Examples/CMakeLists.txt +++ b/src/Examples/CMakeLists.txt @@ -9,6 +9,7 @@ add_subdirectory( transport-equation ) #add_subdirectory( inviscid-flow-vl ) #add_subdirectory( mean-curvature-flow ) add_subdirectory( flows ) +add_subdirectory( turbulent-flows ) ADD_EXECUTABLE( ConfigDescriptionExample ConfigDescriptionExample.cpp ) @@ -91,4 +92,4 @@ ADD_CUSTOM_TARGET( RunExamples ALL DEPENDS if( BUILD_CUDA ) ADD_CUSTOM_TARGET( RunExamples-cuda ALL DEPENDS FileExampleCuda.out ) -ENDIF() \ No newline at end of file +ENDIF() diff --git a/src/Examples/turbulent-flows/CMakeLists.txt b/src/Examples/turbulent-flows/CMakeLists.txt new file mode 100644 index 000000000..bb1362258 --- /dev/null +++ b/src/Examples/turbulent-flows/CMakeLists.txt @@ -0,0 +1,3 @@ +#add_subdirectory( zero-equation-model ) +add_subdirectory( one-equation-model ) +add_subdirectory( two-equation-model ) diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h new file mode 100644 index 000000000..5b19d9cf3 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h @@ -0,0 +1,168 @@ +#include + +#include "DensityBoundaryConditionBoiler.h" +#include "MomentumXBoundaryConditionBoiler.h" +#include "MomentumYBoundaryConditionBoiler.h" +#include "MomentumZBoundaryConditionBoiler.h" +#include "EnergyBoundaryConditionBoiler.h" +#include "TurbulentEnergyBoundaryConditionBoiler.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsBoiler +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::TurbulentEnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->turbulentEnergyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + } + + void setIntensity(const RealType& intensity) + { + this->turbulentEnergyBoundaryConditionsPointer->setIntensity( intensity ); + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h new file mode 100644 index 000000000..6231f6780 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h @@ -0,0 +1,542 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().y() < 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().z() < 0.8 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionBoilers: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h new file mode 100644 index 000000000..412640b54 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h @@ -0,0 +1,853 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + + + this->cavitySpeed + * + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) +{ + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * + ( + ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( + this->cavitySpeed + * + this->cavitySpeed + ) + ); + + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h new file mode 100644 index 000000000..dfe63e076 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h @@ -0,0 +1,594 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h new file mode 100644 index 000000000..83b6282dd --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h @@ -0,0 +1,588 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h new file mode 100644 index 000000000..9d887857c --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h @@ -0,0 +1,563 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h new file mode 100644 index 000000000..e6b63da71 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h @@ -0,0 +1,664 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class TurbulentEnergyBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function> +class TurbulentEnergyBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const TurbulentEnergyBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h new file mode 100644 index 000000000..514caad73 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h @@ -0,0 +1,211 @@ +#include + +#include "DensityBoundaryConditionBoilerModel.h" +#include "MomentumXBoundaryConditionBoilerModel.h" +#include "MomentumYBoundaryConditionBoilerModel.h" +#include "MomentumZBoundaryConditionBoilerModel.h" +#include "EnergyBoundaryConditionBoilerModel.h" +#include "TurbulentEnergyBoundaryConditionBoilerModel.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsBoilerModel +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "vertical-angle", "Vertical angle of throttle in degrees", 0 ); + config.addEntry< double >( prefix + "horizontal-angle", "Horizontal angle of throttle in degrees", 45 ); + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + setZAngle(parameters.getParameter< double >( prefix + "vertical-angle" ) * M_PI / 180.0 ); + setXYAngle(parameters.getParameter< double >( prefix + "horizontal-angle" ) * M_PI / 180.0 ); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setZAngle(const RealType zAngle) + { + this->densityBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumXBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumYBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumZBoundaryConditionsPointer->setZAngle(zAngle); + this->energyBoundaryConditionsPointer->setZAngle(zAngle); + this->turbulentEnergyBoundaryConditionsPointer->setZAngle(zAngle); + } + + void setXYAngle(const RealType xYAngle) + { + this->densityBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumXBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumYBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumZBoundaryConditionsPointer->setXYAngle(xYAngle); + this->turbulentEnergyBoundaryConditionsPointer->setXYAngle(xYAngle); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setIntensity(const RealType& intensity) + { + this->turbulentEnergyBoundaryConditionsPointer->setIntensity( intensity ); + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + RealType horizontalThrottleSpeed = 0; + if(time <= finalTime) + if( time != 0 && finalTime != 0 ) + horizontalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) * ( time / finalTime ); + else + horizontalThrottleSpeed = 0; + else + horizontalThrottleSpeed = finalSpeed; + this->momentumXBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->momentumYBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->momentumZBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->energyBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->turbulentEnergyBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + RealType verticalThrottleSpeed = 0; + if(time <= finalTime) + if( time != 0 && finalTime != 0 ) + verticalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) * ( time / finalTime ); + else + verticalThrottleSpeed = 0; + else + verticalThrottleSpeed = finalSpeed; + this->momentumXBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->momentumYBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->momentumZBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->energyBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->turbulentEnergyBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..a58f32f7c --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h @@ -0,0 +1,580 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().y() < 0.835 * ( entity.getMesh().getDimensions().y() - 1 )) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + // if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..d0475576b --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h @@ -0,0 +1,962 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle energy + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + }; + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle energy + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + if( (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] != 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * ( ( (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + ) + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + ); + else return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->verticalThrottleSpeed + * + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ +const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; +// if for chimney exit + } + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + if( (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] != 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * ( ( (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 2 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 2 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + ) + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + ); + else return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) +// &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->verticalThrottleSpeed + * + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..65648c389 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -0,0 +1,940 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +//throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->zAngle ) + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->zAngle ) + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..e8aa33e88 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h @@ -0,0 +1,941 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +//throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( - 1.0 ) + * std::sin( this->zAngle ) + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) +// down throttle + { + if( + ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) + ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->verticalThrottleSpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..625b74585 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -0,0 +1,838 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( + ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..851b70618 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h @@ -0,0 +1,832 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class TurbulentEnergyBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function> +class TurbulentEnergyBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle TurbulentEnergy + { + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + }; + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle TurbulentEnergy + { + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + } +// if for chimney exit + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ +const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed;; + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; +// if for chimney exit + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed;; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) +// &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed;; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const TurbulentEnergyBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h new file mode 100644 index 000000000..0b80a7c55 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h @@ -0,0 +1,170 @@ +#include + +#include "DensityBoundaryConditionCavity.h" +#include "MomentumXBoundaryConditionCavity.h" +#include "MomentumYBoundaryConditionCavity.h" +#include "MomentumZBoundaryConditionCavity.h" +#include "EnergyBoundaryConditionCavity.h" +#include "TurbulentEnergyBoundaryConditionCavity.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsCavity +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::TurbulentEnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->turbulentEnergyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->turbulentEnergyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->turbulentEnergyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + } + + void setIntensity(const RealType& intensity) + { + this->turbulentEnergyBoundaryConditionsPointer->setIntensity( intensity ); + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h new file mode 100644 index 000000000..c753d324a --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h @@ -0,0 +1,536 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 1, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 1 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h new file mode 100644 index 000000000..ca5d85442 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h @@ -0,0 +1,672 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< 1, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< -1, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + ); + } + if( entity.getCoordinates().y() == 0 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 1 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + ); + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, -1 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + * ( + this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + * + this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + * + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h new file mode 100644 index 000000000..07abfdbeb --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h @@ -0,0 +1,570 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + * ( + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + ); + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h new file mode 100644 index 000000000..a83dd653f --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h @@ -0,0 +1,564 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h new file mode 100644 index 000000000..5fe6f22e5 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h @@ -0,0 +1,554 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h new file mode 100644 index 000000000..05098c7dd --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h @@ -0,0 +1,568 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class TurbulentEnergyBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function> +class TurbulentEnergyBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const TurbulentEnergyBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h new file mode 100644 index 000000000..da9e948ab --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h @@ -0,0 +1,141 @@ +#include +#include +#include +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Function = Functions::Analytic::Constant< Mesh::getMeshDimension(), typename Mesh::RealType >, + int MeshEntitiesDimension = Mesh::getMeshDimension(), + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class BoundaryConditionsDirichlet +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + + } + + void setTimestep(const RealType timestep) + { + + } + + void setGamma(const RealType gamma) + { + + } + + void setPressure(const MeshFunctionPointer& pressure) + { + + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setIntensity(const RealType& intensity) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h new file mode 100644 index 000000000..c2a2a3475 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h @@ -0,0 +1,137 @@ +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class BoundaryConditionsNeumann +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + + } + + void setTimestep(const RealType timestep) + { + + } + + void setGamma(const RealType gamma) + { + + } + + void setPressure(const MeshFunctionPointer& pressure) + { + + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setIntensity(const RealType& intensity) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/CMakeLists.txt b/src/Examples/turbulent-flows/one-equation-model/CMakeLists.txt new file mode 100644 index 000000000..6c5571e6e --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/CMakeLists.txt @@ -0,0 +1,101 @@ +#one-equation-turbulence-model-Lax-Friedrichs + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + oneEquationTurbulenceModelLaxFriedrichs.cpp + oneEquationTurbulenceModelLaxFriedrichs.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-one-equation-turbulence-model-Lax-Friedrichs oneEquationTurbulenceModelLaxFriedrichs.cu) + target_link_libraries (tnl-one-equation-turbulence-model-Lax-Friedrichs ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-one-equation-turbulence-model-Lax-Friedrichs oneEquationTurbulenceModelLaxFriedrichs.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-one-equation-turbulence-model-Lax-Friedrichs + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-one-equation-turbulence-model-Lax-Friedrichs + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#one-equation-turbulence-model-Steger-Warming + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + oneEquationTurbulenceModelStegerWarming.cpp + oneEquationTurbulenceModelStegerWarming.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-one-equation-turbulence-model-Steger-Warming oneEquationTurbulenceModelStegerWarming.cu) + target_link_libraries (tnl-one-equation-turbulence-model-Steger-Warming ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-one-equation-turbulence-model-Steger-Warming oneEquationTurbulenceModelStegerWarming.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-one-equation-turbulence-model-Steger-Warming + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-one-equation-turbulence-model-Steger-Warming + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#one-equation-turbulence-model-Van-Leer + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + oneEquationTurbulenceModelVanLeer.cpp + oneEquationTurbulenceModelVanLeer.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-one-equation-turbulence-model-Van-Leer oneEquationTurbulenceModelVanLeer.cu) + target_link_libraries (tnl-one-equation-turbulence-model-Van-Leer ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-one-equation-turbulence-model-Van-Leer oneEquationTurbulenceModelVanLeer.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-one-equation-turbulence-model-Van-Leer + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-one-equation-turbulence-model-Van-Leer + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#one-equation-turbulence-model-AUSM-plus + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + oneEquationTurbulenceModelAUSMPlus.cpp + oneEquationTurbulenceModelAUSMPlus.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-one-equation-turbulence-model-AUSM-plus oneEquationTurbulenceModelAUSMPlus.cu) + target_link_libraries (tnl-one-equation-turbulence-model-AUSM-plus ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-one-equation-turbulence-model-AUSM-plus oneEquationTurbulenceModelAUSMPlus.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-one-equation-turbulence-model-AUSM-plus + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-one-equation-turbulence-model-AUSM-plus + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/one-equation-model/CMakeLists_separate.txt b/src/Examples/turbulent-flows/one-equation-model/CMakeLists_separate.txt new file mode 100644 index 000000000..cd8e6f870 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/CMakeLists_separate.txt @@ -0,0 +1,101 @@ +#navier-stokes-Lax-Friedrichs + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesLaxFriedrichs.cpp + navierStokesLaxFriedrichs.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cu) + target_link_libraries (tnl-navier-stokes-Lax-Friedrichs ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Lax-Friedrichs + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Lax-Friedrichs + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Steger-Warming + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesStegerWarming.cpp + navierStokesStegerWarming.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cu) + target_link_libraries (tnl-navier-stokes-Steger-Warming ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Steger-Warming + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Steger-Warming + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Van-Leer + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesVanLeer.cpp + navierStokesVanLeer.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cu) + target_link_libraries (tnl-navier-stokes-Van-Leer ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Van-Leer + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Van-Leer + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-AUSM-plus + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesAUSMPlus.cpp + navierStokesAUSMPlus.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cu) + target_link_libraries (tnl-navier-stokes-AUSM-plus ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-AUSM-plus + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-AUSM-plus + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/one-equation-model/CMakeLists_together.txt b/src/Examples/turbulent-flows/one-equation-model/CMakeLists_together.txt new file mode 100644 index 000000000..f26fc6d34 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/CMakeLists_together.txt @@ -0,0 +1,26 @@ +#navier-stokes + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokes.cpp + navierStokes.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cu) + target_link_libraries (tnl-navier-stokes ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/one-equation-model/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/one-equation-model/CompressibleConservativeVariables.h new file mode 100644 index 000000000..23ca0fe8d --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/CompressibleConservativeVariables.h @@ -0,0 +1,179 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ), + turbulentEnergy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + this->turbulentEnergy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + currentOffset += this->energy->getDofs( meshPointer ); + this->turbulentEnergy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ) + + this->turbulentEnergy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setTurbulentEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + __cuda_callable__ + MeshFunctionPointer& getTurbulentEnergy() + { + return this->turbulentEnergy; + } + + __cuda_callable__ + const MeshFunctionPointer& getTurbulentEnergy() const + { + return this->turbulentEnergy; + } + + void setEnergy( MeshFunctionPointer& turbulentEnergy ) + { + this->energy = turbulentEnergy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + MeshFunctionPointer turbulentEnergy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlus.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlus.h new file mode 100644 index 000000000..b9e1de467 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlus.h @@ -0,0 +1,213 @@ +/*************************************************************************** + AUSMPlus.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "AUSMPlusContinuity.h" +#include "AUSMPlusEnergy.h" +#include "AUSMPlusMomentumX.h" +#include "AUSMPlusMomentumY.h" +#include "AUSMPlusMomentumZ.h" +#include "AUSMPlusTurbulentEnergy.h" + +#include "Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = PrandtlKolmogorovOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlus +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + + typedef AUSMPlusContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef AUSMPlusMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef AUSMPlusMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef AUSMPlusMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef AUSMPlusEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef AUSMPlusTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + AUSMPlus() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "AUSMPlus" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + this->turbulentEnergyOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + this->turbulentEnergyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + this->turbulentEnergyOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setCharacteristicLength( RealType& characteristicLength ) + { + this->turbulentEnergyOperatorPointer->setCharacteristicLength( characteristicLength ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setViscosityConstant( RealType& ViscosityConstant ) + { + this->turbulentEnergyOperatorPointer->setViscosityConstant( ViscosityConstant ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h new file mode 100644 index 000000000..2d92e9dc8 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h @@ -0,0 +1,401 @@ +/*************************************************************************** + AUSMPlusContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "AUSMPlusContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType DensityFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity + MachBorderMinus * RightDensity ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return hxInverse * ( + this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return hxInverse * ( + this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->DensityFlux( u[ north ], u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) + - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return hxInverse * ( + this->DensityFlux( u[ west ] , u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->DensityFlux( u[ north ] , u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) + - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + ) + + hzInverse * ( + this->DensityFlux( u[ up ] , u[ center ], velocity_z_up , velocity_z_center, pressure_up , pressure_center ) + - this->DensityFlux( u[ center ], u[ down ] , velocity_z_center, velocity_z_down , pressure_center, pressure_down ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h new file mode 100644 index 000000000..fa7b33b42 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h @@ -0,0 +1,521 @@ +/*************************************************************************** + AUSMPlusEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + AUSMPlusEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "AUSMPlusEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + RealType EnergyFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure, + const RealType& LeftEnergy, + const RealType& RightEnergy ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * ( LeftEnergy + LeftPressure) + MachBorderMinus * ( RightEnergy + RightPressure ) ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->EnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->EnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->EnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->EnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + ) + + hzInverse * ( + this->EnergyFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ], u[ center ] ) + - this->EnergyFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h new file mode 100644 index 000000000..a65ba0174 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h @@ -0,0 +1,205 @@ +/*************************************************************************** + AUSMPlusMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + RealType MainMomentumFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + RealType PressureSplitingPlus = 0; + RealType PressureSplitingMinus = 0; + RealType PressureBorder = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + PressureSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + PressureSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) * (2.0 - LeftMachNumber ) + + 3.0 / 16.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + PressureSplitingPlus = 1.0; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + PressureSplitingMinus = 1.0; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) * (2.0 + RightMachNumber ) + - 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + PressureSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + PressureBorder = PressureSplitingPlus * LeftPressure + PressureSplitingMinus * RightPressure; + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity * LeftVelocity + MachBorderMinus * RightDensity * RightVelocity ) + PressureBorder; + } + + RealType OtherMomentumFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftOtherVelocity, + const RealType& RightOtherVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity * LeftOtherVelocity + MachBorderMinus * RightDensity * RightOtherVelocity ); + } + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType dynamicalViscosity; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h new file mode 100644 index 000000000..1468cf891 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h @@ -0,0 +1,398 @@ +/*************************************************************************** + AUSMPlusMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->OtherMomentumFlux( density_down , density_center, velocity_x_down , velocity_x_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->OtherMomentumFlux( density_center, density_up , velocity_x_center, velocity_x_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h new file mode 100644 index 000000000..d1a8d4304 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h @@ -0,0 +1,371 @@ +/*************************************************************************** + AUSMPlusMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->OtherMomentumFlux( density_down , density_center, velocity_y_down , velocity_y_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->OtherMomentumFlux( density_center, density_up , velocity_y_center, velocity_y_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h new file mode 100644 index 000000000..fcc6183f2 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h @@ -0,0 +1,316 @@ +/*************************************************************************** + AUSMPlusMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_z_west , velocity_z_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_z_center, velocity_z_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_z_south , velocity_z_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->MainMomentumFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->MainMomentumFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h new file mode 100644 index 000000000..787bdab9f --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h @@ -0,0 +1,458 @@ +/*************************************************************************** + AUSMPlusTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "AUSMPlusTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setCharacteristicLength( RealType& characteristicLength ) + { + this->rightHandSide.setCharacteristicLength( characteristicLength ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + } + + void setViscosityConstant( RealType& ViscosityConstant ) + { + this->rightHandSide.setViscosityConstant( ViscosityConstant ); + } + + RealType TurbulentEnergyFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure, + const RealType& LeftTurbulentEnergy, + const RealType& RightTurbulentEnergy ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftTurbulentEnergy + MachBorderMinus * RightTurbulentEnergy ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return hxInverse * ( + this->TurbulentEnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return hxInverse * ( + this->TurbulentEnergyFlux( density_west , density_center , velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center , density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return hxInverse * ( + this->TurbulentEnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ] , u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ] , u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + ) + + hzInverse * ( + this->TurbulentEnergyFlux( density_up , density_center, velocity_z_up , velocity_z_center, pressure_up , pressure_center, u[ up ] , u[ center ]) + - this->TurbulentEnergyFlux( density_center, density_down , velocity_z_center, velocity_z_down , pressure_center, pressure_down , u[ center ], u[ down ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h new file mode 100644 index 000000000..53370ca34 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h @@ -0,0 +1,214 @@ +/*************************************************************************** + LaxFridrichs.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "LaxFridrichsContinuity.h" +#include "LaxFridrichsEnergy.h" +#include "LaxFridrichsMomentumX.h" +#include "LaxFridrichsMomentumY.h" +#include "LaxFridrichsMomentumZ.h" +#include "LaxFridrichsTurbulentEnergy.h" + +#include "Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = PrandtlKolmogorovOperatorRightHandSide< Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichs +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + + typedef LaxFridrichsContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef LaxFridrichsMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef LaxFridrichsMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef LaxFridrichsMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef LaxFridrichsEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef LaxFridrichsTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + LaxFridrichs() + : artificialViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "Lax-Friedrichs" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); + this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->turbulentEnergyOperatorPointer->setArtificialViscosity( artificialViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setCharacteristicLength( RealType& characteristicLength ) + { + this->turbulentEnergyOperatorPointer->setCharacteristicLength( characteristicLength ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setViscosityConstant( RealType& ViscosityConstant ) + { + this->turbulentEnergyOperatorPointer->setViscosityConstant( ViscosityConstant ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + + RealType artificialViscosity; + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h new file mode 100644 index 000000000..e82c9d424 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h @@ -0,0 +1,310 @@ +/*************************************************************************** + LaxFridrichsContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsContinuityBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + RealType artificialViscosity; +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + +// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) +// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h new file mode 100644 index 000000000..16256aa80 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -0,0 +1,349 @@ +/*************************************************************************** + LaxFridrichsEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) + - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east + - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ) + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse + + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) + -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ) + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h new file mode 100644 index 000000000..cde9e58c8 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -0,0 +1,88 @@ +/*************************************************************************** + LaxFridrichsMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsMomentumBase() + : artificialViscosity( 1.0 ){}; + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + } + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h new file mode 100644 index 000000000..57258d1a5 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h @@ -0,0 +1,295 @@ +/*************************************************************************** + LaxFridrichsMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) + - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ) + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_u[ up ] * velocity_z_up ) + - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ) + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h new file mode 100644 index 000000000..4cca02779 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h @@ -0,0 +1,280 @@ +/*************************************************************************** + LaxFridrichsMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ) + + + this->rightHandSide(rho_v, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse + + ( ( rho_v[ up ] * velocity_z_up ) + - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ) + + + this->rightHandSide(rho_v, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h new file mode 100644 index 000000000..1f394bfef --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h @@ -0,0 +1,251 @@ +/*************************************************************************** + LaxFridrichsMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) + -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) + - ( rho_w[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_w[ north ] * velocity_y_north ) + - ( rho_w[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) + - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ) + + + this->rightHandSide(rho_w, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h new file mode 100644 index 000000000..02c03dffa --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h @@ -0,0 +1,342 @@ +/*************************************************************************** + LaxFridrichsTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsTurbulentEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setCharacteristicLength( RealType& characteristicLength ) + { + this->rightHandSide.setCharacteristicLength( characteristicLength ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + } + + void setViscosityConstant( RealType& ViscosityConstant ) + { + this->rightHandSide.setViscosityConstant( ViscosityConstant ); + } + + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + RealType artificialViscosity; +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + +// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) +// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarming.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarming.h new file mode 100644 index 000000000..cec76d37c --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarming.h @@ -0,0 +1,218 @@ +/*************************************************************************** + StegerWarming.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "StegerWarmingContinuity.h" +#include "StegerWarmingEnergy.h" +#include "StegerWarmingMomentumX.h" +#include "StegerWarmingMomentumY.h" +#include "StegerWarmingMomentumZ.h" +#include "StegerWarmingTurbulentEnergy.h" + +#include "Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = PrandtlKolmogorovOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarming +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + + + typedef StegerWarmingContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef StegerWarmingMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef StegerWarmingMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef StegerWarmingMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef StegerWarmingEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef StegerWarmingTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + StegerWarming() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "Steger-Warming"<< std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + this->turbulentEnergyOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + this->turbulentEnergyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + this->turbulentEnergyOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setCharacteristicLength( RealType& characteristicLength ) + { + this->turbulentEnergyOperatorPointer->setCharacteristicLength( characteristicLength ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setViscosityConstant( RealType& ViscosityConstant ) + { + this->turbulentEnergyOperatorPointer->setViscosityConstant( ViscosityConstant ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h new file mode 100644 index 000000000..5fbef7be6 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h @@ -0,0 +1,396 @@ +/*************************************************************************** + StegerWarmingContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h new file mode 100644 index 000000000..f51bf7e53 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h @@ -0,0 +1,560 @@ +/*************************************************************************** + StegerWarmingEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hzInverse * ( + this->positiveEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_z_down , velocity_x_down , velocity_y_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_z_up , velocity_x_up , velocity_y_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h new file mode 100644 index 000000000..e6c6c1fbb --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h @@ -0,0 +1,150 @@ +/*************************************************************************** + StegerWarmingMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + } + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber + 1.0 ) * ( machNumber + 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber + 1.0 ) * (machNumber + 1.0 ) ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber - 1.0 ) * (machNumber - 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber - 1.0 ) * ( machNumber - 1.0 ) ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h new file mode 100644 index 000000000..c6588083c --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h @@ -0,0 +1,356 @@ +/*************************************************************************** + StegerWarmingMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h new file mode 100644 index 000000000..210fb6087 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h @@ -0,0 +1,326 @@ +/*************************************************************************** + StegerWarmingMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h new file mode 100644 index 000000000..135352d2f --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h @@ -0,0 +1,282 @@ +/*************************************************************************** + StegerWarmingMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 0-hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h new file mode 100644 index 000000000..774b076df --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h @@ -0,0 +1,452 @@ +/*************************************************************************** + StegerWarmingTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setCharacteristicLength( RealType& characteristicLength ) + { + this->rightHandSide.setCharacteristicLength( characteristicLength ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + } + + void setViscosityConstant( RealType& ViscosityConstant ) + { + this->rightHandSide.setViscosityConstant( ViscosityConstant ); + } + + RealType positiveTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); + else if ( machNumber <= 1.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); + else + return turbulentEnergy * velocity; + }; + + RealType negativeTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return turbulentEnergy * velocity; + else if ( machNumber <= 0.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); + else if ( machNumber <= 1.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + -hzInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_down , velocity_z_down , pressure_down , u[ down ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_up , velocity_z_up , pressure_up , u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeer.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeer.h new file mode 100644 index 000000000..49f31db83 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeer.h @@ -0,0 +1,213 @@ +/*************************************************************************** + VanLeer.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "VanLeerContinuity.h" +#include "VanLeerEnergy.h" +#include "VanLeerMomentumX.h" +#include "VanLeerMomentumY.h" +#include "VanLeerMomentumZ.h" +#include "VanLeerTurbulentEnergy.h" + +#include "Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = PrandtlKolmogorovOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeer +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + + typedef VanLeerContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef VanLeerMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef VanLeerMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef VanLeerMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef VanLeerEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef VanLeerTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + VanLeer() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "VanLeer" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + this->turbulentEnergyOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + this->turbulentEnergyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + this->turbulentEnergyOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setCharacteristicLength( RealType& characteristicLength ) + { + this->turbulentEnergyOperatorPointer->setCharacteristicLength( characteristicLength ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setViscosityConstant( RealType& ViscosityConstant ) + { + this->turbulentEnergyOperatorPointer->setViscosityConstant( ViscosityConstant ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerContinuity.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerContinuity.h new file mode 100644 index 000000000..3b497125a --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerContinuity.h @@ -0,0 +1,396 @@ +/*************************************************************************** + VanLeerContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "VanLeerContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + RealType multiply (const RealType& a, const RealType& b ) const + { + return a * b; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerEnergy.h new file mode 100644 index 000000000..3e372e54a --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerEnergy.h @@ -0,0 +1,592 @@ +/*************************************************************************** + VanLeerEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + VanLeerEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "VanLeerEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hzInverse * ( + this->positiveEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_z_down , velocity_x_down , velocity_y_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_z_up , velocity_x_up , velocity_y_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h new file mode 100644 index 000000000..d8e80c103 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h @@ -0,0 +1,145 @@ +/*************************************************************************** + VanLeerMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * ( - 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType dynamicalViscosity; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h new file mode 100644 index 000000000..04e41c015 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h @@ -0,0 +1,410 @@ +/*************************************************************************** + VanLeerMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h new file mode 100644 index 000000000..65ac84828 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h @@ -0,0 +1,381 @@ +/*************************************************************************** + VanLeerMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h new file mode 100644 index 000000000..125166cb8 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h @@ -0,0 +1,322 @@ +/*************************************************************************** + VanLeerMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h new file mode 100644 index 000000000..fa4cb0db4 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h @@ -0,0 +1,446 @@ +/*************************************************************************** + VanLeerTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "VanLeerTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setCharacteristicLength( RealType& characteristicLength ) + { + this->rightHandSide.setCharacteristicLength( characteristicLength ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + } + + void setViscosityConstant( RealType& ViscosityConstant ) + { + this->rightHandSide.setViscosityConstant( ViscosityConstant ); + } + + RealType positiveTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return turbulentEnergy * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); + else + return turbulentEnergy * velocity; + }; + + RealType negativeTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return turbulentEnergy * velocity; + else if ( machNumber <= 1.0 ) + return - turbulentEnergy * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + -hzInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_down , velocity_z_down , pressure_down , u[ down ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_up , velocity_z_up , pressure_up , u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovContinuityOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovContinuityOperatorRightHandSide.h new file mode 100644 index 000000000..8d5780563 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovContinuityOperatorRightHandSide.h @@ -0,0 +1,218 @@ +/*************************************************************************** + PrandtlKolmogorovContinuityOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlKolmogorovContinuityRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + protected: + +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlKolmogorovContinuityRightHandSide +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovContinuityRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovContinuityRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovContinuityRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovContinuityRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovContinuityRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovContinuityRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + + return 0; + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovEnergyOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovEnergyOperatorRightHandSide.h new file mode 100644 index 000000000..23989021f --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovEnergyOperatorRightHandSide.h @@ -0,0 +1,687 @@ +/*************************************************************************** + PrandtlKolmogorovEnergyOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlKolmogorovEnergyRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + PrandtlKolmogorovEnergyRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + MeshFunctionPointer turbulentEnergy; + + MeshFunctionPointer density; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlKolmogorovEnergyRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovEnergyRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return +// 1D uT_11_x + 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity +// 1D_t_11_x + + + 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse + + + 2.0 / 3.0 * ( velocity_x_east * density_east * turbulentEnergy_east + - velocity_x_west * density_west * turbulentEnergy_west + ) * hxInverse / 2; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovEnergyRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return +// 2D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// vT_12_x + + ( ( velocity_x_northEast * velocity_y_east - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_west + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center - velocity_y_center * velocity_y_west + - velocity_y_center * velocity_y_center + velocity_y_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_21_y + + ( ( velocity_y_northEast * velocity_x_north - velocity_y_southEast * velocity_x_south + - velocity_y_northWest * velocity_x_north + velocity_y_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center - velocity_x_center * velocity_x_south + - velocity_x_center * velocity_x_center + velocity_x_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 2D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// ut_11_x + + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east * turbulentViscosity_east - velocity_y_southEast * velocity_x_east * turbulentViscosity_east + - velocity_y_northWest * velocity_x_west * turbulentViscosity_west + velocity_y_southWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( velocity_x_east * density_east * turbulentEnergy_east + - velocity_x_west * density_west * turbulentEnergy_west + ) * hxInverse / 2 + ) +// vt_12_x + + ( ( velocity_x_northEast * velocity_y_east * turbulentViscosity_east - velocity_x_southEast * velocity_y_east * turbulentViscosity_east + - velocity_x_northWest * velocity_y_west * turbulentViscosity_west + velocity_x_southWest * velocity_y_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_west * turbulentViscosity_west + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_west * velocity_y_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// ut_21_y + + ( ( velocity_y_northEast * velocity_x_north * turbulentViscosity_north - velocity_y_southEast * velocity_x_south * turbulentViscosity_south + - velocity_y_northWest * velocity_x_north * turbulentViscosity_north + velocity_y_southWest * velocity_x_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_south * turbulentViscosity_south + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_south * velocity_x_south * turbulentViscosity_south + ) * hySquareInverse + ) +// vt_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_south * turbulentViscosity_south + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_south * velocity_y_south * turbulentViscosity_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north * turbulentViscosity_north - velocity_x_southEast * velocity_y_south * turbulentViscosity_south + - velocity_x_northWest * velocity_y_north * turbulentViscosity_north + velocity_x_southWest * velocity_y_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( velocity_y_north * density_north * turbulentEnergy_north + - velocity_y_south * density_south * turbulentEnergy_south + ) * hyInverse / 2 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovEnergyRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + const RealType& turbulentEnergy_up = this->turbulentEnergy.template getData< DeviceType >()[ up ]; + const RealType& turbulentEnergy_down = this->turbulentEnergy.template getData< DeviceType >()[ down ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east + - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// vT_12_x + + ( ( velocity_x_northEast * velocity_y_east - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_west + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center - velocity_y_center * velocity_y_west + - velocity_y_center * velocity_y_center + velocity_y_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// wT_13_x + + ( ( velocity_x_upEast * velocity_z_east - velocity_x_downEast * velocity_z_east + - velocity_x_upWest * velocity_z_west + velocity_x_downWest * velocity_z_west + ) * hxInverse * hzInverse / 4 + + ( velocity_z_east * velocity_z_center - velocity_z_center * velocity_z_west + - velocity_z_center * velocity_z_center + velocity_z_west * velocity_z_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_21_y + + ( ( velocity_y_northEast * velocity_x_north - velocity_y_southEast * velocity_x_south + - velocity_y_northWest * velocity_x_north + velocity_y_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center - velocity_x_center * velocity_x_south + + velocity_x_center * velocity_x_center + velocity_x_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// wT_23_y + + ( ( velocity_y_upNorth * velocity_z_north - velocity_y_downNorth * velocity_y_north + - velocity_y_upSouth * velocity_z_south + velocity_y_downSouth * velocity_z_south + ) * hyInverse * hzInverse / 4 + + ( velocity_z_north * velocity_z_center - velocity_z_center * velocity_z_south + - velocity_z_center * velocity_z_center + velocity_z_south * velocity_z_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// uT_31_z + + ( ( velocity_x_up * velocity_x_center - velocity_x_center * velocity_x_center + - velocity_x_center * velocity_x_down + velocity_x_down * velocity_x_down + ) * hzSquareInverse + + ( velocity_z_upEast * velocity_x_up - velocity_z_downEast * velocity_x_down + - velocity_z_upWest * velocity_x_up + velocity_z_downWest * velocity_x_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_z + + ( ( velocity_z_upNorth * velocity_y_up - velocity_z_downNorth * velocity_y_down + - velocity_z_upSouth * velocity_y_up + velocity_z_downSouth * velocity_y_down + ) * hyInverse * hzInverse / 4 + + ( velocity_x_up * velocity_y_center - velocity_x_center * velocity_y_down + - velocity_x_center * velocity_y_center + velocity_x_down * velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down + - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down + - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down + - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// ut_11_x + + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east * turbulentViscosity_east - velocity_y_southEast * velocity_x_east * turbulentViscosity_east + - velocity_y_northWest * velocity_x_west * turbulentViscosity_west + velocity_y_southWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east * turbulentViscosity_east - velocity_z_downEast * velocity_x_east * turbulentViscosity_east + - velocity_z_upWest * velocity_x_west * turbulentViscosity_west + velocity_z_downWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( velocity_y_north * density_north * turbulentEnergy_north + - velocity_y_south * density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// vt_12_x + + ( ( velocity_x_northEast * velocity_y_east * turbulentViscosity_east - velocity_x_southEast * velocity_y_east * turbulentViscosity_east + - velocity_x_northWest * velocity_y_west * turbulentViscosity_west + velocity_x_southWest * velocity_y_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_west * turbulentViscosity_west + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_west * velocity_y_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// wt_13_x + + ( ( velocity_x_upEast * velocity_z_east * turbulentViscosity_east - velocity_x_downEast * velocity_z_east * turbulentViscosity_east + - velocity_x_upWest * velocity_z_west * turbulentViscosity_west + velocity_x_downWest * velocity_z_west * turbulentViscosity_west + ) * hxInverse * hzInverse / 4 + + ( velocity_z_east * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_west * turbulentViscosity_west + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_west * velocity_z_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// ut_21_y + + ( ( velocity_y_northEast * velocity_x_north * turbulentViscosity_north - velocity_y_southEast * velocity_x_south * turbulentViscosity_south + - velocity_y_northWest * velocity_x_north * turbulentViscosity_north + velocity_y_southWest * velocity_x_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_south * turbulentViscosity_south + + velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_south * velocity_x_south * turbulentViscosity_south + ) * hySquareInverse + ) +// vt_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_south * turbulentViscosity_south + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_south * velocity_y_south * turbulentViscosity_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north * turbulentViscosity_north - velocity_x_southEast * velocity_y_south * turbulentViscosity_south + - velocity_x_northWest * velocity_y_north * turbulentViscosity_north + velocity_x_southWest * velocity_y_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north * turbulentViscosity_north - velocity_z_downNorth * velocity_y_north * turbulentViscosity_north + - velocity_z_upSouth * velocity_y_south * turbulentViscosity_south + velocity_z_downSouth * velocity_y_south * turbulentViscosity_south + ) * hyInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( velocity_y_north * density_north * turbulentEnergy_north + - velocity_y_south * density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// wt_23_y + + ( ( velocity_y_upNorth * velocity_z_north * turbulentViscosity_north - velocity_y_downNorth * velocity_y_north * turbulentViscosity_north + - velocity_y_upSouth * velocity_z_south * turbulentViscosity_south + velocity_y_downSouth * velocity_z_south * turbulentViscosity_south + ) * hyInverse * hzInverse / 4 + + ( velocity_z_north * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_south * turbulentViscosity_south + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_south * velocity_z_south * turbulentViscosity_south + ) * hySquareInverse + ) +// ut_31_z + + ( ( velocity_x_up * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_center * turbulentViscosity_center + - velocity_x_center * velocity_x_down * turbulentViscosity_down + velocity_x_down * velocity_x_down * turbulentViscosity_down + ) * hzSquareInverse + + ( velocity_z_upEast * velocity_x_up * turbulentViscosity_up - velocity_z_downEast * velocity_x_down * turbulentViscosity_down + - velocity_z_upWest * velocity_x_up * turbulentViscosity_up + velocity_z_downWest * velocity_x_down * turbulentViscosity_down + ) * hxInverse * hzInverse / 4 + ) +// vt_32_z + + ( ( velocity_z_upNorth * velocity_y_up * turbulentViscosity_up - velocity_z_downNorth * velocity_y_down * turbulentViscosity_down + - velocity_z_upSouth * velocity_y_up * turbulentViscosity_up + velocity_z_downSouth * velocity_y_down * turbulentViscosity_down + ) * hyInverse * hzInverse / 4 + + ( velocity_x_up * velocity_y_center * turbulentViscosity_center - velocity_x_center * velocity_y_down * turbulentViscosity_down + - velocity_x_center * velocity_y_center * turbulentViscosity_center + velocity_x_down * velocity_y_down * turbulentViscosity_down + ) * hzSquareInverse + ) +// wt_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_down * turbulentViscosity_down + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_down * velocity_z_down * turbulentViscosity_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up * turbulentViscosity_up - velocity_y_downNorth * velocity_z_down * turbulentViscosity_down + - velocity_y_upSouth * velocity_z_up * turbulentViscosity_up + velocity_y_downSouth * velocity_z_down * turbulentViscosity_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up * turbulentViscosity_up - velocity_x_downEast * velocity_z_down * turbulentViscosity_down + - velocity_x_upWest * velocity_z_up * turbulentViscosity_up + velocity_x_downWest * velocity_z_down * turbulentViscosity_down + ) * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( velocity_z_up * density_up * turbulentEnergy_up + - velocity_z_down * density_down * turbulentEnergy_down + ) * hzInverse / 2 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumBaseOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumBaseOperatorRightHandSide.h new file mode 100644 index 000000000..b56a25b07 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumBaseOperatorRightHandSide.h @@ -0,0 +1,75 @@ +/*************************************************************************** + PrandtlKolmogorovMomentumRightHandSideBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlKolmogorovMomentumRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + PrandtlKolmogorovMomentumRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + MeshFunctionPointer turbulentEnergy; + + MeshFunctionPointer density; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumXOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumXOperatorRightHandSide.h new file mode 100644 index 000000000..0e76c056d --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumXOperatorRightHandSide.h @@ -0,0 +1,450 @@ +/*************************************************************************** + PrandtlKolmogorovMomentumXRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "PrandtlKolmogorovMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlKolmogorovMomentumXRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovMomentumXRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return +// 1D T_11_x + 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity +// 1D t_11_x + + + 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse + + + 2.0 / 3.0 * ( density_east * turbulentEnergy_east + - density_west * turbulentEnergy_west + ) * hxInverse / 2; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return +// 2D T_11_x + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// t_11_x + + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( density_east * turbulentEnergy_east + - density_west * turbulentEnergy_west + ) * hxInverse / 2 + ) +// t_21_y + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + ) * hySquareInverse + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D T_11_x + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hxSquareInverse + ) * this->dynamicalViscosity +// T_31_z + + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + + ( velocity_x_up - 2 * velocity_x_center + velocity_x_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +//t_11_x + + + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest + velocity_z_downWest ) + ) * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( density_east * turbulentEnergy_east + - density_west * turbulentEnergy_west + ) * hxInverse / 2 + ) +// t_21_y + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north - turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + ) * hySquareInverse + ) +// t_31_z + + ( ( turbulentViscosity_up * ( velocity_z_upEast - velocity_z_upWest ) - turbulentViscosity_down * ( velocity_z_downEast - velocity_z_downWest ) + ) * hxInverse * hzInverse / 4 + + ( turbulentViscosity_up * velocity_x_up - ( turbulentViscosity_up + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_down + ) * hzSquareInverse + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumYOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumYOperatorRightHandSide.h new file mode 100644 index 000000000..1e5f64b41 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumYOperatorRightHandSide.h @@ -0,0 +1,417 @@ +/*************************************************************************** + PrandtlKolmogorovMomentumYRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "PrandtlKolmogorovMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlKolmogorovMomentumYRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovMomentumYRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovMomentumYRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + + return +// 2D T_22_y + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_12_x + + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east + ) * hxSquareInverse + ) * this->dynamicalViscosity + + +// t_22_y + ( 4.0 / 3.0 * ( turbulentViscosity_north * velocity_y_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_x_northEast - velocity_x_northWest ) - turbulentViscosity_south * ( velocity_x_southEast - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( density_north * turbulentEnergy_north + - density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// t_12_x + + ( ( turbulentViscosity_east * (velocity_x_northEast - velocity_x_southEast ) - turbulentViscosity_west * (velocity_x_northWest - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_east * velocity_y_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_west + ) * hxSquareInverse + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovMomentumYRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// T_12_y + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east - 2 * velocity_y_center + velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// 3D T_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_y + + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + + ( velocity_y_up - 2 * velocity_y_center + velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity + + +// t_12_x + ( ( turbulentViscosity_east * ( velocity_x_northEast - velocity_x_southEast ) - turbulentViscosity_west * ( velocity_x_northWest - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_east * velocity_y_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_west + ) * hxSquareInverse + ) +// t_22_y + + ( 4.0 / 3.0 * ( turbulentViscosity_north * velocity_y_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_x_northEast - velocity_x_northWest ) - turbulentViscosity_south * ( velocity_x_southEast - velocity_x_southWest) + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_z_upNorth - velocity_z_downNorth ) - turbulentViscosity_south * ( velocity_z_upSouth - velocity_z_downSouth ) + ) * hyInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( density_north * turbulentEnergy_north + - density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// t_32_z + + ( ( turbulentViscosity_up * ( velocity_z_upNorth - velocity_z_upSouth ) - turbulentViscosity_down * ( velocity_z_downNorth - velocity_z_downSouth ) + ) * hyInverse * hzInverse / 4 + + ( turbulentViscosity_up * velocity_y_up - ( turbulentViscosity_up + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_down + ) * hzSquareInverse + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumZOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumZOperatorRightHandSide.h new file mode 100644 index 000000000..cf642efad --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumZOperatorRightHandSide.h @@ -0,0 +1,343 @@ +/*************************************************************************** + PrandtlKolmogorovMomentumZRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "PrandtlKolmogorovMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlKolmogorovMomentumZRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovMomentumZRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovMomentumZRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_up = this->turbulentEnergy.template getData< DeviceType >()[ up ]; + const RealType& turbulentEnergy_down = this->turbulentEnergy.template getData< DeviceType >()[ down ]; + + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// T_13_x + ( ( velocity_z_east - 2 * velocity_z_center + velocity_z_west ) + * hxSquareInverse + + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// T_23_y + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + * hySquareInverse + ) + * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// t_13_x + + ( ( turbulentViscosity_east * velocity_z_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_west ) + * hxSquareInverse + + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest + velocity_x_downWest ) ) + * hxInverse * hzInverse / 4 + ) +// t_23_y + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + * hySquareInverse + ) +// t_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( density_up * turbulentEnergy_up + - density_down * turbulentEnergy_down + ) * hzInverse / 2 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h new file mode 100644 index 000000000..b437cc7aa --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h @@ -0,0 +1,160 @@ +/*************************************************************************** + PrandtlKolmogorovOpratorRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "PrandtlKolmogorovContinuityOperatorRightHandSide.h" +#include "PrandtlKolmogorovEnergyOperatorRightHandSide.h" +#include "PrandtlKolmogorovMomentumXOperatorRightHandSide.h" +#include "PrandtlKolmogorovMomentumYOperatorRightHandSide.h" +#include "PrandtlKolmogorovMomentumZOperatorRightHandSide.h" +#include "PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlKolmogorovOperatorRightHandSide +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef PrandtlKolmogorovContinuityRightHandSide< Mesh, Real, Index > ContinuityOperatorRightHandSideType; + typedef PrandtlKolmogorovMomentumXRightHandSide< Mesh, Real, Index > MomentumXOperatorRightHandSideType; + typedef PrandtlKolmogorovMomentumYRightHandSide< Mesh, Real, Index > MomentumYOperatorRightHandSideType; + typedef PrandtlKolmogorovMomentumZRightHandSide< Mesh, Real, Index > MomentumZOperatorRightHandSideType; + typedef PrandtlKolmogorovEnergyRightHandSide< Mesh, Real, Index > EnergyOperatorRightHandSideType; + typedef PrandtlKolmogorovTurbulentEnergyRightHandSide< Mesh, Real, Index > TurbulentEnergyOperatorRightHandSideType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorRightHandSideType > ContinuityOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumXOperatorRightHandSideType > MomentumXOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumYOperatorRightHandSideType > MomentumYOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumZOperatorRightHandSideType > MomentumZOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< EnergyOperatorRightHandSideType > EnergyOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorRightHandSideType > TurbulentEnergyOperatorRightHandSidePointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + PrandtlKolmogorovOperatorRightHandSide() + : dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + return true; + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumXOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumYOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumZOperatorRightHandSidePointer->setVelocity( velocity ); + this->energyOperatorRightHandSidePointer->setVelocity( velocity ); + this->turbulentEnergyOperatorRightHandSidePointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->momentumXOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->turbulentEnergyOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorRightHandSidePointer->setDensity( density ); + this->momentumYOperatorRightHandSidePointer->setDensity( density ); + this->momentumZOperatorRightHandSidePointer->setDensity( density ); + this->energyOperatorRightHandSidePointer->setDensity( density ); + this->turbulentEnergyOperatorRightHandSidePointer->setDenity( density ); + } + + const ContinuityOperatorRightHandSidePointer& getContinuityOperatorRightHandSide() const + { + return this->continuityOperatorRightHandSidePointer; + } + + const MomentumXOperatorRightHandSidePointer& getMomentumXOperatorRightHandSide() const + { + return this->momentumXOperatorRightHandSidePointer; + } + + const MomentumYOperatorRightHandSidePointer& getMomentumYOperatorRightHandSide() const + { + return this->momentumYOperatorRightHandSidePointer; + } + + const MomentumZOperatorRightHandSidePointer& getMomentumZOperatorRightHandSide() const + { + return this->momentumZOperatorRightHandSidePointer; + } + + const EnergyOperatorRightHandSidePointer& getEnergyOperatorRightHandSide() const + { + return this->energyOperatorRightHandSidePointer; + } + + const TurbulentEnergyOperatorRightHandSidePointer& getTurbulentEnergyOperatorRightHandSide() const + { + return this->turbulentEnergyOperatorRightHandSidePointer; + } + + protected: + + ContinuityOperatorRightHandSidePointer continuityOperatorPointer; + MomentumXOperatorRightHandSidePointer momentumXOperatorPointer; + MomentumYOperatorRightHandSidePointer momentumYOperatorPointer; + MomentumZOperatorRightHandSidePointer momentumZOperatorPointer; + EnergyOperatorRightHandSidePointer energyOperatorPointer; + TurbulentEnergyOperatorRightHandSidePointer turbulentEnergyOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h new file mode 100644 index 000000000..d48f5c3c4 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h @@ -0,0 +1,574 @@ +/*************************************************************************** + PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlKolmogorovTurbulentEnergyRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + + + static String getType() + { + return String( "LaxFridrichsTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + void setCharacteristicLength( const RealType& characteristicLength ) + { + this->characteristicLength = characteristicLength; + } + + void setViscosityConstant( const RealType& viscosityConstant ) + { + this->viscosityConstant = viscosityConstant; + } + + void setSigmaK( const RealType& sigmaK ) + { + this->sigmaK = sigmaK; + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + } + + void setCaracteristicLength( RealType& characteristicLength ) + { + this->characteristicLength = characteristicLength; + } + + void setSigmaK( RealType& sigmaK ) + { + this->sigmaK = sigmaK; + } + + void setViscosityConstant( RealType& ViscosityConstant ) + { + this->viscosityConstant = ViscosityConstant; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + MeshFunctionPointer turbulentEnergy; + + MeshFunctionPointer density; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; + + RealType characteristicLength; + + RealType viscosityConstant; + + RealType sigmaK; +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlKolmogorovTurbulentEnergyRightHandSide +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovTurbulentEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovTurbulentEnergyRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovTurbulentEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return + 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + * this->dynamicalViscosity + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + - density_center / this->characteristicLength * std::pow( turbulentEnergy_center, 2.0 / 3.0 ) + + + this->dynamicalViscosity + * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) + * hxSquareInverse + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + ) * hxSquareInverse / this->sigmaK; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovTurbulentEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovTurbulentEnergyRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovTurbulentEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return + ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + + ( ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + + - density_center / this->characteristicLength * std::pow( turbulentEnergy_center, 2.0 / 3.0 ) + + + this->dynamicalViscosity + * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) + * hxSquareInverse + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + ) * hxSquareInverse / this->sigmaK + + + this->dynamicalViscosity + * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) + * hySquareInverse + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + ) * hySquareInverse / this->sigmaK; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlKolmogorovTurbulentEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlKolmogorovTurbulentEnergyRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlKolmogorovTurbulentEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + const RealType& turbulentEnergy_up = this->turbulentEnergy.template getData< DeviceType >()[ up ]; + const RealType& turbulentEnergy_down = this->turbulentEnergy.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_x_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 +// vT_12_x + + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_east - velocity_y_west ) * hxInverse / 2 +// wT_13_x + + ( ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_z_east - velocity_z_west ) * hxInverse / 2 +// uT_21_y + + ( ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_north - velocity_x_south ) * hyInverse / 2 +// 3D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 +// wT_23_y + + ( ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + + ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_z_north - velocity_z_south ) * hyInverse / 2 +// uT_31_z + + ( ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_up - velocity_x_down ) * hzInverse / 2 +// T_32_z + + ( ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + + ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_up - velocity_y_down ) * hzInverse / 2 +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + + - density_center / this->characteristicLength * std::pow( turbulentEnergy_center, 2.0 / 3.0 ) + + + this->dynamicalViscosity + * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) + * hxSquareInverse + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + ) * hxSquareInverse / this->sigmaK + + + this->dynamicalViscosity + * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) + * hySquareInverse + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + ) * hySquareInverse / this->sigmaK + + + this->dynamicalViscosity + * ( turbulentEnergy_up - 2 * turbulentEnergy_center + turbulentEnergy_down ) + * hySquareInverse + + ( turbulentEnergy_up * turbulentViscosity_up - turbulentEnergy_center * turbulentViscosity_down + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_down * turbulentViscosity_down + ) * hySquareInverse / this->sigmaK; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/PhysicalVariablesGetter.h b/src/Examples/turbulent-flows/one-equation-model/PhysicalVariablesGetter.h new file mode 100644 index 000000000..c51e14d65 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/PhysicalVariablesGetter.h @@ -0,0 +1,204 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { + +template< typename Mesh > +class PhysicalVariablesGetter +{ + public: + + typedef Mesh MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + VelocityGetter( MeshFunctionPointer density, + MeshFunctionPointer momentum ) + : density( density ), momentum( momentum ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return momentum.template getData< DeviceType >()( meshEntity ) / + density.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, momentum; + }; + + class PressureGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + PressureGetter( MeshFunctionPointer density, + MeshFunctionPointer energy, + VelocityFieldPointer momentum, + const RealType& gamma ) + : density( density ), energy( energy ), momentum( momentum ), gamma( gamma ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + const RealType e = energy.template getData< DeviceType >()( meshEntity ); + const RealType rho = density.template getData< DeviceType >()( meshEntity ); + const RealType momentumNorm = momentum.template getData< DeviceType >().getVector( meshEntity ).lpNorm( 2.0 ); + if( rho == 0.0 ) + return 0; + else + return ( gamma - 1.0 ) * ( e - 0.5 * momentumNorm * momentumNorm / rho ); + } + + protected: + const MeshFunctionPointer density, energy; + const VelocityFieldPointer momentum; + const RealType gamma; + }; + + class TurbulentEnergyGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + TurbulentEnergyGetter( MeshFunctionPointer density, + MeshFunctionPointer turbulentEnergyXDensity ) + : density( density ), turbulentEnergyXDensity( turbulentEnergyXDensity ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return turbulentEnergyXDensity.template getData< DeviceType >()( meshEntity ) / + density.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, turbulentEnergyXDensity; + }; + + class TurbulentViscosityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + TurbulentViscosityGetter( MeshFunctionPointer density, + MeshFunctionPointer turbulentEnergy, + RealType viscosityConstant, + RealType specificLength ) + : density( density ), turbulentEnergy( turbulentEnergy ), viscosityConstant( viscosityConstant ), specificLength( specificLength ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( turbulentEnergy.template getData< DeviceType >()( meshEntity ) < 0.0 ) + return 0; + else + return density.template getData< DeviceType >()( meshEntity ) * viscosityConstant * specificLength + * std::sqrt(turbulentEnergy.template getData< DeviceType >()( meshEntity ) ); + } + + protected: + const MeshFunctionPointer density, turbulentEnergy; + const RealType viscosityConstant, specificLength; + }; + + + void getVelocity( const ConservativeVariablesPointer& conservativeVariables, + VelocityFieldPointer& velocity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), + ( *conservativeVariables->getMomentum() )[ i ] ); + evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); + } + } + + void getPressure( const ConservativeVariablesPointer& conservativeVariables, + const RealType& gamma, + MeshFunctionPointer& pressure ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; + Pointers::SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), + conservativeVariables->getEnergy(), + conservativeVariables->getMomentum(), + gamma ); + evaluator.evaluate( pressure, pressureGetter ); + } + + void getTurbulentEnergy( const ConservativeVariablesPointer& conservativeVariables, + MeshFunctionPointer& turbulentEnergy_no_rho ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, TurbulentEnergyGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< TurbulentEnergyGetter, DeviceType > turbulentEnergyGetter( conservativeVariables->getDensity(), + conservativeVariables->getTurbulentEnergy() ); + evaluator.evaluate( turbulentEnergy_no_rho, turbulentEnergyGetter ); + } + } + + void getTurbulentViscosity( const ConservativeVariablesPointer& conservativeVariables, + MeshFunctionPointer& turbulentEnergy_no_rho, + const RealType& viscosityConstant, + const RealType& specificLength, + MeshFunctionPointer& turbulentViscosity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, TurbulentViscosityGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< TurbulentViscosityGetter, DeviceType > turbulentViscosityGetter( conservativeVariables->getDensity(), + turbulentEnergy_no_rho, + viscosityConstant, + specificLength ); + evaluator.evaluate( turbulentViscosity, turbulentViscosityGetter ); + } + } + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/RiemannProblemInitialCondition.h b/src/Examples/turbulent-flows/one-equation-model/RiemannProblemInitialCondition.h new file mode 100644 index 000000000..b9b190c71 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/RiemannProblemInitialCondition.h @@ -0,0 +1,1663 @@ +/*************************************************************************** + RiemannProblemInitialCondition.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { +template +class RiemannProblemInitialConditionSetter +{ + +}; + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 1,MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setTurbulentEnergy(RealType NWUTurbulentEnergy, + RealType NEUTurbulentEnergy, + RealType SWUTurbulentEnergy, + RealType SEUTurbulentEnergy, + RealType NWDTurbulentEnergy, + RealType NEDTurbulentEnergy, + RealType SWDTurbulentEnergy, + RealType SEDTurbulentEnergy) + { + this->NWUTurbulentEnergy = NWUTurbulentEnergy; + this->NEUTurbulentEnergy = NEUTurbulentEnergy; + this->SWUTurbulentEnergy = SWUTurbulentEnergy; + this->SEUTurbulentEnergy = SEUTurbulentEnergy; + this->NWDTurbulentEnergy = NWDTurbulentEnergy; + this->NEDTurbulentEnergy = NEDTurbulentEnergy; + this->SWDTurbulentEnergy = SWDTurbulentEnergy; + this->SEDTurbulentEnergy = SEDTurbulentEnergy; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + }; + + + void placeTurbulentEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWDTurbulentEnergy); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEDTurbulentEnergy); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 2,MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setTurbulentEnergy(RealType NWUTurbulentEnergy, + RealType NEUTurbulentEnergy, + RealType SWUTurbulentEnergy, + RealType SEUTurbulentEnergy, + RealType NWDTurbulentEnergy, + RealType NEDTurbulentEnergy, + RealType SWDTurbulentEnergy, + RealType SEDTurbulentEnergy) + { + this->NWUTurbulentEnergy = NWUTurbulentEnergy; + this->NEUTurbulentEnergy = NEUTurbulentEnergy; + this->SWUTurbulentEnergy = SWUTurbulentEnergy; + this->SEUTurbulentEnergy = SEUTurbulentEnergy; + this->NWDTurbulentEnergy = NWDTurbulentEnergy; + this->NEDTurbulentEnergy = NEDTurbulentEnergy; + this->SWDTurbulentEnergy = SWDTurbulentEnergy; + this->SEDTurbulentEnergy = SEDTurbulentEnergy; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); + } + }; + + void placeTurbulentEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEDTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NEDTurbulentEnergy); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setTurbulentEnergy(RealType NWUTurbulentEnergy, + RealType NEUTurbulentEnergy, + RealType SWUTurbulentEnergy, + RealType SEUTurbulentEnergy, + RealType NWDTurbulentEnergy, + RealType NEDTurbulentEnergy, + RealType SWDTurbulentEnergy, + RealType SEDTurbulentEnergy) + { + this->NWUTurbulentEnergy = NWUTurbulentEnergy; + this->NEUTurbulentEnergy = NEUTurbulentEnergy; + this->SWUTurbulentEnergy = SWUTurbulentEnergy; + this->SEUTurbulentEnergy = SEUTurbulentEnergy; + this->NWDTurbulentEnergy = NWDTurbulentEnergy; + this->NEDTurbulentEnergy = NEDTurbulentEnergy; + this->SWDTurbulentEnergy = SWDTurbulentEnergy; + this->SEDTurbulentEnergy = SEDTurbulentEnergy; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWDMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEDMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NWDMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NEDMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); + } + }; + + void placeTurbulentEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEDTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NEDTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWUTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEUTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWUTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEUTurbulentEnergy); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + +template< typename Mesh > +class RiemannProblemInitialCondition +{ + public: + + typedef Mesh MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; + + RiemannProblemInitialCondition() + : discontinuityPlacement( 0.5 ), + leftDensity( 1.0 ), rightDensity( 1.0 ), + leftVelocity( -2.0 ), rightVelocity( 2.0 ), + leftPressure( 0.4 ), rightPressure( 0.4 ), + gamma( 1.67 ){} + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "discontinuity-placement-0", "x-coordinate of the discontinuity placement.", 0.5 ); + config.addEntry< double >( prefix + "discontinuity-placement-1", "y-coordinate of the discontinuity placement.", 0.5 ); + config.addEntry< double >( prefix + "discontinuity-placement-2", "z-coordinate of the discontinuity placement.", 0.5 ); +/* + config.addEntry< double >( prefix + "left-density", "Density on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-density", "Density on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "left-velocity-0", "x-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "left-velocity-1", "y-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "left-velocity-2", "z-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-velocity-0", "x-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "right-velocity-1", "y-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "right-velocity-2", "z-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "left-pressure", "Pressure on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-pressure", "Pressure on the right side of the discontinuity.", 0.0 ); +*/ + config.addEntry< double >( prefix + "NWU-density", "This sets a value of northwest up density.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-0", "This sets a value of northwest up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-1", "This sets a value of northwest up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-2", "This sets a value of northwest up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-pressure", "This sets a value of northwest up pressure.", 1.0 ); + config.addEntry< double >( prefix + "SWU-density", "This sets a value of southwest up density.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-0", "This sets a value of southwest up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-1", "This sets a value of southwest up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-2", "This sets a value of southwest up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-pressure", "This sets a value of southwest up pressure.", 1.0 ); + config.addEntry< double >( prefix + "NWD-density", "This sets a value of northwest down density.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-0", "This sets a value of northwest down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-1", "This sets a value of northwest down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-2", "This sets a value of northwest down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-pressure", "This sets a value of northwest down pressure.", 1.0 ); + config.addEntry< double >( prefix + "SWD-density", "This sets a value of southwest down density.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-0", "This sets a value of southwest down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-1", "This sets a value of southwest down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-2", "This sets a value of southwest down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-pressure", "This sets a value of southwest down pressure.", 1.0 ); + config.addEntry< double >( prefix + "NEU-density", "This sets a value of northeast up density.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-0", "This sets a value of northeast up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-1", "This sets a value of northeast up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-2", "This sets a value of northeast up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-pressure", "This sets a value of northeast up pressure.", 1.0 ); + config.addEntry< double >( prefix + "SEU-density", "This sets a value of southeast up density.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-0", "This sets a value of southeast up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-1", "This sets a value of southeast up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-2", "This sets a value of southeast up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-pressure", "This sets a value of southeast up pressure.", 1.0 ); + config.addEntry< double >( prefix + "NED-density", "This sets a value of northeast down density.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-0", "This sets a value of northeast down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-1", "This sets a value of northeast down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-2", "This sets a value of northeast down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-pressure", "This sets a value of northeast down pressure.", 1.0 ); + config.addEntry< double >( prefix + "SED-density", "This sets a value of southeast down density.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-0", "This sets a value of southeast down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-1", "This sets a value of southeast down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-2", "This sets a value of southeast down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-pressure", "This sets a value of southeast down pressure.", 1.0 ); + config.addEntry< double >( prefix + "gamma", "Gamma in the ideal gas state equation.", 1.4 ); + + config.addEntry< String >( prefix + "initial", " One of predefined initial condition.", "none"); + config.addEntryEnum< String >( "none" ); + config.addEntryEnum< String >( "1D_2" ); + config.addEntryEnum< String >( "1D_3a" ); + config.addEntryEnum< String >( "1D_4" ); + config.addEntryEnum< String >( "1D_5" ); + config.addEntryEnum< String >( "1D_6" ); + config.addEntryEnum< String >( "1D_Noh" ); + config.addEntryEnum< String >( "1D_peak" ); + config.addEntryEnum< String >( "2D_3" ); + config.addEntryEnum< String >( "2D_4" ); + config.addEntryEnum< String >( "2D_6" ); + config.addEntryEnum< String >( "2D_12" ); + config.addEntryEnum< String >( "2D_15" ); + config.addEntryEnum< String >( "2D_17" ); + } + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + String initial = parameters.getParameter< String >( prefix + "initial" ); + if(initial == prefix + "none") + { + this->intensity = parameters.getParameter< double >( "turbulence-intensity" ); + this->discontinuityPlacement.setup( parameters, prefix + "discontinuity-placement-" ); + this->gamma = parameters.getParameter< double >( prefix + "gamma" ); +/* + this->leftVelocity.setup( parameters, prefix + "left-velocity-" ); + this->rightVelocity.setup( parameters, prefix + "right-velocity-" ); + this->leftDensity = parameters.getParameter< double >( prefix + "left-density" ); + this->rightDensity = parameters.getParameter< double >( prefix + "right-density" ); + this->leftPressure = parameters.getParameter< double >( prefix + "left-pressure" ); + this->rightPressure = parameters.getParameter< double >( prefix + "right-pressure" ); +*/ + + this->NWUDensity = parameters.getParameter< RealType >( prefix + "NWU-density" ); + this->NWUVelocity.setup( parameters, prefix + "NWU-velocity-" ); + this->NWUPressure = parameters.getParameter< RealType >( prefix + "NWU-pressure" ); + this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); + this->NWUMomentum = NWUVelocity * NWUDensity; + this->NWUTurbulentEnergy = this->NWUDensity * TurbulentEnergy( NWUVelocity, this->intensity); + + this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); + this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); + this->SWUPressure = parameters.getParameter< RealType >( prefix + "SWU-pressure" ); + this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); + this->SWUMomentum = SWUVelocity * SWUDensity; + this->SWUTurbulentEnergy = SWUDensity * TurbulentEnergy( SWUVelocity, this->intensity); + + this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); + this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); + this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); + this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); + this->NWDMomentum = NWDVelocity * NWDDensity; + this->NWDTurbulentEnergy = NWDDensity * TurbulentEnergy( NWDVelocity, this->intensity); + + this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); + this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); + this->SWDPressure = parameters.getParameter< RealType >( prefix + "SWD-pressure" ); + this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); + this->SWDMomentum = SWDVelocity * SWDDensity; + this->SWDTurbulentEnergy = SWDDensity * TurbulentEnergy( SWDVelocity, this->intensity); + + this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); + this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); + this->NEUPressure = parameters.getParameter< RealType >( prefix + "NEU-pressure" ); + this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); + this->NEUMomentum = NEUVelocity * NEUDensity; + this->NEUTurbulentEnergy = NEUDensity * TurbulentEnergy( NEUVelocity, this->intensity); + + this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); + this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); + this->SEUPressure = parameters.getParameter< RealType >( prefix + "SEU-pressure" ); + this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); + this->SEUMomentum = SEUVelocity * SEUDensity; + this->SEUTurbulentEnergy = SEUDensity * TurbulentEnergy( SEUVelocity, this->intensity); + + this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); + this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); + this->NEDPressure = parameters.getParameter< RealType >( prefix + "NED-pressure" ); + this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); + this->NEDMomentum = NEDVelocity * NEDDensity; + this->NEDTurbulentEnergy = NEDDensity * TurbulentEnergy( NEDVelocity, this->intensity); + + this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); + this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); + this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); + this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); + this->SEDMomentum = SEDVelocity * SEDDensity; + this->SEDTurbulentEnergy = SEDDensity * TurbulentEnergy( SEDVelocity, this->intensity); + } + if(initial == prefix + "1D_2") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -2.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 2.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_3a") + predefinedInitialCondition( 1.4, 0.8, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 1000.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.01, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -19.59745, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -19.59745, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_4") + predefinedInitialCondition( 1.666, 0.4, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 5.99924, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 5.99242, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 460.894, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 46.095, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 19.5975, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -6.19633, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_5") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_6") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.1, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_Noh") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.000001, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.000001, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_peak") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 0.12612, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 6.5915, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 782.929, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 3.15449, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 8.90470, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 2.26542, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_3") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5323, 0.138, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.5, 0.5323, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.3, 0.029, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.5, 0.3, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 1.206, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.206, 1.206, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 1.206, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_4") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5065, 1.1, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.1, 0.5065, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.35, 1.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.1, 0.35, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.8939, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.8939, 0.8939, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.8939, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + + if(initial == prefix + "2D_6") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 2.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 3.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.75, 0.5, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -0.75, 0.5, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.75, -0.5, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -0.75, -0.5, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_12") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 1.0, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.5313, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.4, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.7276, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.7276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + + if(initial == prefix + "2D_15") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5197, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 0.5313, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.4, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + -0.6259, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.1, -0.3, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.1, -0.3, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.1, 0.4276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_17") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 2.0, 1.0625, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 0.5197, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.2145, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, -0.4, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 1.1259, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + return true; + } + + void setDiscontinuityPlacement( const PointType& v ) + { + this->discontinuityPlacement = v; + } + + const PointType& getDiscontinuityPlasement() const + { + return this->discontinuityPlacement; + } + + void setLeftDensity( const RealType& leftDensity ) + { + this->leftDensity = leftDensity; + } + + const RealType& getLeftDensity() const + { + return this->leftDensity; + } + + void setRightDensity( const RealType& rightDensity ) + { + this->rightDensity = rightDensity; + } + + const RealType& getRightDensity() const + { + return this->rightDensity; + } + + void setLeftVelocity( const PointType& leftVelocity ) + { + this->leftVelocity = leftVelocity; + } + + const PointType& getLeftVelocity() const + { + return this->leftVelocity; + } + + void setRightVelocity( const RealType& rightVelocity ) + { + this->rightVelocity = rightVelocity; + } + + const PointType& getRightVelocity() const + { + return this->rightVelocity; + } + + void setLeftPressure( const RealType& leftPressure ) + { + this->leftPressure = leftPressure; + } + + const RealType& getLeftPressure() const + { + return this->leftPressure; + } + + void setRightPressure( const RealType& rightPressure ) + { + this->rightPressure = rightPressure; + } + + const RealType& getRightPressure() const + { + return this->rightPressure; + } + + + void predefinedInitialCondition( double preGamma, double preDiscX, double preDiscY, double preDiscZ, + double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ) + + { + this->intensity = 1.0; + this->discontinuityPlacement = PointLoad(preDiscX, preDiscY, preDiscZ); + this->gamma = preGamma; + + this->NWUDensity = preNWUDensity; + this->NWUVelocity = PointLoad(preNWUVelocityX, preNWUVelocityY, preNWUVelocityZ); + this->NWUPressure = preNWUPressure; + this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); + this->NWUMomentum = NWUVelocity * NWUDensity; + this->NWUTurbulentEnergy = NWUDensity * TurbulentEnergy( NWUVelocity, this->intensity); + + this->SWUDensity = preNWUDensity; + this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); + this->SWUPressure = preSWUPressure; + this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); + this->SWUMomentum = SWUVelocity * SWUDensity; + this->SWUTurbulentEnergy = SWUDensity * TurbulentEnergy( SWUVelocity, this->intensity); + + this->NWDDensity = preNWDDensity; + this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); + this->NWDPressure = preNWDPressure; + this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); + this->NWDMomentum = NWDVelocity * NWDDensity; + this->NWDTurbulentEnergy = NWDDensity * TurbulentEnergy( NWDVelocity, this->intensity); + + this->SWDDensity = preSWDDensity; + this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); + this->SWDPressure = preSWDPressure; + this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); + this->SWDMomentum = SWDVelocity * SWDDensity; + this->SWDTurbulentEnergy = SWDDensity * TurbulentEnergy( SWDVelocity, this->intensity); + + this->NEUDensity = preNEUDensity; + this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); + this->NEUPressure = preNEUPressure; + this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); + this->NEUMomentum = NEUVelocity * NEUDensity; + this->NEUTurbulentEnergy = NEUDensity * TurbulentEnergy( NEUVelocity, this->intensity); + + this->SEUDensity = preSEUDensity; + this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); + this->SEUPressure = preSEUPressure; + this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); + this->SEUMomentum = SEUVelocity * SEUDensity; + this->SEUTurbulentEnergy = TurbulentEnergy( SEUVelocity, this->intensity); + + this->NEDDensity = preNEDDensity; + this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); + this->NEDPressure = preNEDPressure; + this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); + this->NEDMomentum = NEDVelocity * NEDDensity; + this->NEDTurbulentEnergy = NEDDensity * TurbulentEnergy( NEDVelocity, this->intensity); + + this->SEDDensity = preSEDDensity; + this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); + this->SEDPressure = preSEDPressure; + this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); + this->SEDMomentum = SEDVelocity * SEDDensity; + this->SEDTurbulentEnergy = SEDDensity * TurbulentEnergy( SEDVelocity, this->intensity); + + } + + PointType PointLoad( RealType ValueX, RealType ValueY, RealType ValueZ) + { + PointType point; + switch (Dimensions) + { + case 1: point[ 0 ] = ValueX; + break; + case 2: point[ 0 ] = ValueX; + point[ 1 ] = ValueY; + break; + case 3: point[ 0 ] = ValueX; + point[ 1 ] = ValueY; + point[ 2 ] = ValueZ; + break; + } + return point; + } + + RealType Energy( RealType Density, RealType Pressure, RealType gamma, PointType Velocity) + { + RealType energy; + switch (Dimensions) + { + case 1: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ))); + break; + case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); + break; + case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 2 ], 2 ))); + break; // druhou mocninu ps8t jako sou4in + } + return energy; + } + + RealType TurbulentEnergy( PointType Velocity, RealType intensity ) + { + RealType turbulentEnergy; + switch (Dimensions) + { + case 1: turbulentEnergy = 3.0 / 2.0 * intensity * intensity * ((std::pow(Velocity[ 0 ], 2 ))); + break; + case 2: turbulentEnergy = 3.0 / 2.0 * intensity * intensity * ((std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); + break; + case 3: turbulentEnergy = 3.0 / 2.0 * intensity * intensity * ((std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 2 ], 2 ))); + break; // druhou mocninu ps8t jako sou4in + } + return turbulentEnergy; + } + + void setInitialCondition( CompressibleConservativeVariables< MeshType >& conservativeVariables, + const PointType& center = PointType( 0.0 ) ) + { + RiemannProblemInitialConditionSetter* variablesSetter = new RiemannProblemInitialConditionSetter; + variablesSetter->setGamma(this->gamma); + variablesSetter->setDensity(this->NWUDensity, + this->NEUDensity, + this->SWUDensity, + this->SEUDensity, + this->NWDDensity, + this->NEDDensity, + this->SWDDensity, + this->SEDDensity); + variablesSetter->setMomentum(this->NWUMomentum, + this->NEUMomentum, + this->SWUMomentum, + this->SEUMomentum, + this->NWDMomentum, + this->NEDMomentum, + this->SWDMomentum, + this->SEDMomentum); + variablesSetter->setEnergy(this->NWUEnergy, + this->NEUEnergy, + this->SWUEnergy, + this->SEUEnergy, + this->NWDEnergy, + this->NEDEnergy, + this->SWDEnergy, + this->SEDEnergy); + variablesSetter->setTurbulentEnergy(this->NWUTurbulentEnergy, + this->NEUTurbulentEnergy, + this->SWUTurbulentEnergy, + this->SEUTurbulentEnergy, + this->NWDTurbulentEnergy, + this->NEDTurbulentEnergy, + this->SWDTurbulentEnergy, + this->SEDTurbulentEnergy); + variablesSetter->setDiscontinuity(this->discontinuityPlacement); + variablesSetter->placeDensity(conservativeVariables); + variablesSetter->placeMomentum(conservativeVariables); + variablesSetter->placeEnergy(conservativeVariables); + variablesSetter->placeTurbulentEnergy(conservativeVariables); + +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + +/* + typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; + typedef Operators::Analytic::Sign< Dimensions, RealType > SignType; + typedef Functions::OperatorFunction< SignType, VectorNormType > InitialConditionType; + typedef SharedPointer< InitialConditionType, DeviceType > InitialConditionPointer; + + InitialConditionPointer initialCondition; + initialCondition->getFunction().setCenter( center ); + initialCondition->getFunction().setMaxNorm( true ); + initialCondition->getFunction().setRadius( discontinuityPlacement[ 0 ] ); + discontinuityPlacement *= 1.0 / discontinuityPlacement[ 0 ]; + for( int i = 1; i < Dimensions; i++ ) + discontinuityPlacement[ i ] = 1.0 / discontinuityPlacement[ i ]; + initialCondition->getFunction().setAnisotropy( discontinuityPlacement ); + initialCondition->getFunction().setMultiplicator( -1.0 ); + + Functions::MeshFunctionEvaluator< MeshFunctionType, InitialConditionType > evaluator; +*/ + /**** + * Density + */ +/* + conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); +*/ +/* + initialCondition->getOperator().setPositiveValue( leftDensity ); + initialCondition->getOperator().setNegativeValue( rightDensity ); + evaluator.evaluate( conservativeVariables.getDensity(), initialCondition ); + conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); +*/ + /**** + * Momentum + */ + +/* + for( int i = 0; i < Dimensions; i++ ) + { + initialCondition->getOperator().setPositiveValue( leftDensity * leftVelocity[ i ] ); + initialCondition->getOperator().setNegativeValue( rightDensity * rightVelocity[ i ] ); + evaluator.evaluate( conservativeVariables.getMomentum()[ i ], initialCondition ); + } +*/ + /**** + * Energy + */ +/* + conservativeVariables.getEnergy()->write( "energy-init", "gnuplot" ); +*/ +/* + const RealType leftKineticEnergy = leftVelocity.lpNorm( 2.0 ); + const RealType rightKineticEnergy = rightVelocity.lpNorm( 2.0 ); + const RealType leftEnergy = leftPressure / ( gamma - 1.0 ) + 0.5 * leftDensity * leftKineticEnergy * leftKineticEnergy; + const RealType rightEnergy = rightPressure / ( gamma - 1.0 ) + 0.5 * rightDensity * rightKineticEnergy * rightKineticEnergy; + initialCondition->getOperator().setPositiveValue( leftEnergy ); + initialCondition->getOperator().setNegativeValue( rightEnergy ); + evaluator.evaluate( (* conservativeVariables.getEnergy()), initialCondition ); + (* conservativeVariables.getEnergy())->write( "energy-init", "gnuplot" ); +*/ + } + + + protected: + + PointType discontinuityPlacement; + PointType NWUVelocity, NEUVelocity, SWUVelocity, SEUVelocity, NWDVelocity, NEDVelocity, SWDVelocity, SEDVelocity; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUPressure, NEUPressure, SWUPressure, SEUPressure, NWDPressure, NEDPressure, SWDPressure, SEDPressure; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + RealType intensity; + RealType leftDensity, rightDensity; + PointType leftVelocity, rightVelocity; + RealType leftPressure, rightPressure; + + RealType gamma; // gamma in the ideal gas state equation +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/one-equation-model/flowsBuildConfigTag.h b/src/Examples/turbulent-flows/one-equation-model/flowsBuildConfigTag.h new file mode 100644 index 000000000..c40b793b9 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/flowsBuildConfigTag.h @@ -0,0 +1,72 @@ +#ifndef FLOWSBUILDCONFIGTAG_H_ +#define FLOWSBUILDCONFIGTAG_H_ + +#include +#include + +namespace TNL { + +class flowsBuildConfigTag{}; + +namespace Solvers { + +/**** + * Turn off support for float and long double. + */ +template<> struct ConfigTagReal< flowsBuildConfigTag, float > { enum { enabled = false }; }; +template<> struct ConfigTagReal< flowsBuildConfigTag, long double > { enum { enabled = false }; }; + +/**** + * Turn off support for short int and long int indexing. + */ +template<> struct ConfigTagIndex< flowsBuildConfigTag, short int >{ enum { enabled = false }; }; +template<> struct ConfigTagIndex< flowsBuildConfigTag, long int >{ enum { enabled = false }; }; + +//template< int Dimension > struct ConfigTagDimension< flowsBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; + +/**** + * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. + */ +/*template< int Dimension, typename Real, typename Device, typename Index > + struct ConfigTagMesh< flowsBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > + { enum { enabled = ConfigTagDimension< flowsBuildConfigTag, Dimension >::enabled && + ConfigTagReal< flowsBuildConfigTag, Real >::enabled && + ConfigTagDevice< flowsBuildConfigTag, Device >::enabled && + ConfigTagIndex< flowsBuildConfigTag, Index >::enabled }; }; +*/ +/**** + * Please, chose your preferred time discretisation here. + */ +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; + +/**** + * Only the Runge-Kutta-Merson solver is enabled by default. + */ +template<> struct ConfigTagExplicitSolver< flowsBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; + +} // namespace Solvers + +namespace Meshes { +namespace BuildConfigTags { + +template< int Dimensions > struct GridDimensionTag< flowsBuildConfigTag, Dimensions >{ enum { enabled = true }; }; + +/**** + * Turn off support for float and long double. + */ +template<> struct GridRealTag< flowsBuildConfigTag, float > { enum { enabled = false }; }; +template<> struct GridRealTag< flowsBuildConfigTag, long double > { enum { enabled = false }; }; + +/**** + * Turn off support for short int and long int indexing. + */ +template<> struct GridIndexTag< flowsBuildConfigTag, short int >{ enum { enabled = false }; }; +template<> struct GridIndexTag< flowsBuildConfigTag, long int >{ enum { enabled = false }; }; + +} // namespace BuildConfigTags +} // namespace Meshes +} // namespace TNL + +#endif /* FLOWSBUILDCONFIGTAG_H_ */ diff --git a/src/Examples/turbulent-flows/one-equation-model/flowsRhs.h b/src/Examples/turbulent-flows/one-equation-model/flowsRhs.h new file mode 100644 index 000000000..e0b8c7fac --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/flowsRhs.h @@ -0,0 +1,35 @@ +#ifndef FLOWSRHS_H_ +#define FLOWSRHS_H_ + +#include + +namespace TNL { + +template< typename Mesh, typename Real >class flowsRhs + : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > + { + public: + + typedef Mesh MeshType; + typedef Real RealType; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + template< typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshEntity& entity, + const Real& time = 0.0 ) const + { +// typedef typename MeshEntity::MeshType::PointType PointType; +// PointType v = entity.getCenter(); + return 0.0; + } +}; + +} //namespace TNL + +#endif /* FLOWSRHS_H_ */ diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.cpp b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.cpp new file mode 100644 index 000000000..0b4d7cae1 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.cpp @@ -0,0 +1 @@ +#include "oneEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.cu b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.cu new file mode 100644 index 000000000..0b4d7cae1 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.cu @@ -0,0 +1 @@ +#include "oneEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.h new file mode 100644 index 000000000..7390dc6d9 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModel.h @@ -0,0 +1,276 @@ +#include +#include +#include +#include +#include +#include "oneEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/One-Equation-Turbulence-Model/Lax-Friedrichs/LaxFridrichs.h" +#include "DifferentialOperators/One-Equation-Turbulence-Model/Steger-Warming/StegerWarming.h" +#include "DifferentialOperators/One-Equation-Turbulence-Model/VanLeer/VanLeer.h" +#include "DifferentialOperators/One-Equation-Turbulence-Model/AUSM+/AUSMPlus.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class oneEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< String >( "differential-operator", "Choose the differential operator.", "Lax-Friedrichs"); + config.addEntryEnum< String >( "Lax-Friedrichs" ); + config.addEntryEnum< String >( "Steger-Warming" ); + config.addEntryEnum< String >( "VanLeer" ); + config.addEntryEnum< String >( "AUSMPlus" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class oneEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef oneEquationTurbulenceModelOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); + if( differentialOperatorType == "Lax-Friedrichs" ) + { + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "Steger-Warming" ) + { + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "VanLeer" ) + { + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "AUSMPlus" ) + { + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + + + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< oneEquationTurbulenceModelSetter, oneEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.cpp b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.cpp new file mode 100644 index 000000000..0dbfccb3b --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.cpp @@ -0,0 +1 @@ +#include "oneEquationTurbulenceModelAUSMPlus.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.cu b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.cu new file mode 100644 index 000000000..0dbfccb3b --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.cu @@ -0,0 +1 @@ +#include "oneEquationTurbulenceModelAUSMPlus.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.h new file mode 100644 index 000000000..fa1dc84d4 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.h @@ -0,0 +1,142 @@ +//#include +#include +#include +#include +#include +#include +#include "oneEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/One-Equation-Turbulence-Model/AUSM+/AUSMPlus.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class oneEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "characteristic-length", "Value of characteristic mixing length", 1.0 ); + config.addEntry< double >( "viscosity-constant", "Value of viscosity constant", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); + typedef Meshes::Grid< 3 > Mesh; + AUSMPlus< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class oneEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef PrandtlKolmogorovOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< oneEquationTurbulenceModelSetter, oneEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.cpp b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.cpp new file mode 100644 index 000000000..d2b3d16c4 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.cpp @@ -0,0 +1 @@ +#include "oneEquationTurbulenceModelLaxFriedrichs.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.cu b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.cu new file mode 100644 index 000000000..d2b3d16c4 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.cu @@ -0,0 +1 @@ +#include "oneEquationTurbulenceModelLaxFriedrichs.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.h new file mode 100644 index 000000000..924a08337 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.h @@ -0,0 +1,142 @@ +//#include +#include +#include +#include +#include +#include +#include "oneEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/One-Equation-Turbulence-Model/Lax-Friedrichs/LaxFridrichs.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class oneEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "characteristic-length", "Value of characteristic mixing length", 1.0 ); + config.addEntry< double >( "viscosity-constant", "Value of viscosity constant", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); + typedef Meshes::Grid< 3 > Mesh; + LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class oneEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef PrandtlKolmogorovOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< oneEquationTurbulenceModelSetter, oneEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem.h new file mode 100644 index 000000000..bb8ae1afd --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem.h @@ -0,0 +1,145 @@ +/*************************************************************************** + oneEquationTurbulenceModelProblem.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include "CompressibleConservativeVariables.h" + + +using namespace TNL::Problems; + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +class oneEquationTurbulenceModelProblem: + public PDEProblem< Mesh, + Communicator, + typename InviscidOperators::RealType, + typename Mesh::DeviceType, + typename InviscidOperators::IndexType > +{ + public: + + typedef typename InviscidOperators::RealType RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef typename InviscidOperators::IndexType IndexType; + typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; + + typedef Communicator CommunicatorType; + + using typename BaseType::MeshType; + using typename BaseType::MeshPointer; + using typename BaseType::DofVectorType; + using typename BaseType::DofVectorPointer; + static const int Dimensions = Mesh::getMeshDimension(); + + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; + typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; + typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; + + static String getType(); + + String getPrologHeader() const; + + void writeProlog( Logger& logger, + const Config::ParameterContainer& parameters ) const; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ); + + bool setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ); + + template< typename Matrix > + bool setupLinearSystem( Matrix& matrix ); + + bool makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ); + + IndexType getDofs() const; + + void bindDofs( DofVectorPointer& dofs ); + + void getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ); + + + void applyBoundaryConditions( const RealType& time, + DofVectorPointer& dofs ); + + template< typename Matrix > + void assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs, + Matrix& matrix, + DofVectorPointer& rightHandSide ); + + bool postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ); + + protected: + + InviscidOperatorsPointer inviscidOperatorsPointer; + + BoundaryConditionPointer boundaryConditionPointer; + RightHandSidePointer rightHandSidePointer; + + ConservativeVariablesPointer conservativeVariables, + conservativeVariablesRHS; + + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::ContinuityOperatorType, typename BoundaryCondition::DensityBoundaryConditionsType, RightHandSide > explicitUpdaterContinuity; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumXOperatorType, typename BoundaryCondition::MomentumXBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumX; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumYOperatorType, typename BoundaryCondition::MomentumYBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumY; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumZOperatorType, typename BoundaryCondition::MomentumZBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumZ; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::EnergyOperatorType, typename BoundaryCondition::EnergyBoundaryConditionsType, RightHandSide > explicitUpdaterEnergy; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::TurbulentEnergyOperatorType, typename BoundaryCondition::TurbulentEnergyBoundaryConditionsType, RightHandSide > explicitUpdaterTurbulentEnergy; + + + VelocityFieldPointer velocity; + MeshFunctionPointer pressure; + MeshFunctionPointer turbulentViscosity; + MeshFunctionPointer turbulentEnergy; + + RealType gamma; + RealType speedIncrement; + RealType cavitySpeed; + RealType speedIncrementUntil; + RealType finalSpeed; + RealType startSpeed; + RealType speedIncrementUntilHThrottle; + RealType finalSpeedHThrottle; + RealType startSpeedHThrottle; + RealType characteristicLength; + RealType sigmaK; + RealType viscosityConstant; + RealType intensity; +}; + +} // namespace TNL + +#include "oneEquationTurbulenceModelProblem_impl.h" + diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem_impl.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem_impl.h new file mode 100644 index 000000000..449b58ec2 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem_impl.h @@ -0,0 +1,538 @@ +/*************************************************************************** + oneEquationTurbulenceModelProblem_impl.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "RiemannProblemInitialCondition.h" +#include "CompressibleConservativeVariables.h" +#include "PhysicalVariablesGetter.h" +#include "oneEquationTurbulenceModelProblem.h" + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getType() +{ + return String( "oneEquationTurbulenceModelProblem< " ) + Mesh :: getType() + " >"; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getPrologHeader() const +{ + return String( "flow solver" ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const +{ + /**** + * Add data you want to have in the computation report (log) as follows: + * logger.writeParameter< double >( "Parameter description", parameter ); + */ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setup( const Config::ParameterContainer& parameters, + const String& prefix ) +{ + if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || + ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || + ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) + return false; + this->gamma = parameters.getParameter< double >( "gamma" ); + this->startSpeed = parameters.getParameter< double >( "start-speed" ); + this->finalSpeed = parameters.getParameter< double >( "final-speed" ); + this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); + this->startSpeedHThrottle = parameters.getParameter< double >( "start-speed-h-throttle" ); + this->finalSpeedHThrottle = parameters.getParameter< double >( "final-speed-h-throttle" ); + this->speedIncrementUntilHThrottle = parameters.getParameter< RealType >( "speed-increment-until-h-throttle" ); + this->characteristicLength = parameters.getParameter< double >( "characteristic-length" ); + this->viscosityConstant = parameters.getParameter< double >( "viscosity-constant" ); + this->sigmaK = parameters.getParameter< double >( "sigma-k" ); + this->intensity = parameters.getParameter< double >( "turbulence-intensity" ); + velocity->setMesh( this->getMesh() ); + pressure->setMesh( this->getMesh() ); + + /**** + * Set-up operators + */ + + this->inviscidOperatorsPointer->setCharacteristicLength( this->characteristicLength ); + this->inviscidOperatorsPointer->setViscosityConstant( this->viscosityConstant ); + this->inviscidOperatorsPointer->setSigmaK( this->sigmaK ); + this->inviscidOperatorsPointer->setVelocity( this->velocity ); + this->inviscidOperatorsPointer->setPressure( this->pressure ); + this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); + this->inviscidOperatorsPointer->setGamma( this->gamma ); + this->inviscidOperatorsPointer->setTurbulentViscosity( this->turbulentViscosity ); + this->inviscidOperatorsPointer->setTurbulentEnergy( this->turbulentEnergy ); + + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); + this->explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer->getDensityBoundaryCondition() ); + this->explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); + + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); + this->explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer->getMomentumXBoundaryCondition() ); + this->explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); + + if( Dimensions > 1 ) + { + this->explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); + this->explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer->getMomentumYBoundaryCondition() ); + this->explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); + this->explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer->getMomentumZBoundaryCondition() ); + this->explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); + this->explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer->getEnergyBoundaryCondition() ); + this->explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); + + /**** + * Turbulent energy equation + */ + this->explicitUpdaterTurbulentEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getTurbulentEnergyOperator() ); + this->explicitUpdaterTurbulentEnergy.setBoundaryConditions( this->boundaryConditionPointer->getTurbulentEnergyBoundaryCondition() ); + this->explicitUpdaterTurbulentEnergy.setRightHandSide( this->rightHandSidePointer ); + + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +typename oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >::IndexType +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getDofs() const +{ + /**** + * Return number of DOFs (degrees of freedom) i.e. number + * of unknowns to be resolved by the main solver. + */ + return this->conservativeVariables->getDofs( this->getMesh() ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +bindDofs( DofVectorPointer& dofVector ) +{ + this->conservativeVariables->bind( this->getMesh(), dofVector ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ) +{ + CompressibleConservativeVariables< MeshType > conservativeVariables; + conservativeVariables.bind( this->getMesh(), dofs ); + const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); + this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); + this->speedIncrement = parameters.getParameter< RealType >( "speed-increment" ); + this->cavitySpeed = parameters.getParameter< RealType >( "cavity-speed" ); + if( initialConditionType == "riemann-problem" ) + { + RiemannProblemInitialCondition< MeshType > initialCondition; + if( ! initialCondition.setup( parameters ) ) + return false; + initialCondition.setInitialCondition( conservativeVariables ); + return true; + } + std::cerr << "Unknown initial condition " << initialConditionType << std::endl; + return false; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +bool +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setupLinearSystem( Matrix& matrix ) +{ +/* const IndexType dofs = this->getDofs(); + typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; + CompressedRowLengthsVectorType rowLengths; + if( ! rowLengths.setSize( dofs ) ) + return false; + MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; + matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, + differentialOperator, + boundaryCondition, + rowLengths ); + matrix.setDimensions( dofs, dofs ); + if( ! matrix.setCompressedRowLengths( rowLengths ) ) + return false;*/ + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ) +{ + std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; + + this->bindDofs( dofs ); + PhysicalVariablesGetter< MeshType > physicalVariablesGetter; + physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + + FileName fileName; + fileName.setExtension( "tnl" ); + fileName.setIndex( step ); + fileName.setFileNameBase( "density-" ); +// if( ! this->conservativeVariables->getDensity()->save( fileName.getFileName() ) ) + this->conservativeVariables->getDensity()->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "velocity-" ); +// if( ! this->velocity->save( fileName.getFileName() ) ) + this->velocity->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "pressure-" ); +// if( ! this->pressure->save( fileName.getFileName() ) ) + this->pressure->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "energy-" ); +// if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) + this->conservativeVariables->getEnergy()->save( fileName.getFileName() ); +// return false; + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ) +{ + typedef typename MeshType::Cell Cell; + + /**** + * Bind DOFs + */ + this->conservativeVariables->bind( this->getMesh(), _u ); + this->conservativeVariablesRHS->bind( this->getMesh(), _fu ); + + /**** + * Resolve the physical variables + */ + PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; + physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + physicalVariables.getTurbulentEnergy( this->conservativeVariables, this->turbulentEnergy ); + physicalVariables.getTurbulentViscosity( this->conservativeVariables, this->turbulentEnergy, this->viscosityConstant, this->characteristicLength, this->turbulentViscosity ); + + /**** + * Set-up operators + */ + + this->inviscidOperatorsPointer->setTau( tau ); + + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getDensity(), + this->conservativeVariablesRHS->getDensity() ); + +// this->explicitUpdaterContinuity.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, +// this->conservativeVariables->getDensity() ); + + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); + if( Dimensions > 1 ) + { + this->explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getEnergy(), // uRhoVelocityX, + this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); + + + /**** + * Turbulent energy equation + */ + this->explicitUpdaterTurbulentEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getTurbulentEnergy(), // uRhoVelocityX, + this->conservativeVariablesRHS->getTurbulentEnergy() ); //, fuRhoVelocityX ); + + /*this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); + this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); + this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); + getchar();*/ + +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +applyBoundaryConditions( const RealType& time, + DofVectorPointer& dofs ) +{ + /**** + * Update Boundary Conditions + */ + if(this->speedIncrementUntil > time ) + { + this->boundaryConditionPointer->setTimestep(this->speedIncrement); + } + else + { + this->boundaryConditionPointer->setTimestep(0); + } + this->boundaryConditionPointer->setSpeed(this->intensity); + this->boundaryConditionPointer->setIntensity(this->cavitySpeed); + this->boundaryConditionPointer->setCompressibleConservativeVariables(this->conservativeVariables); + this->boundaryConditionPointer->setGamma(this->gamma); + this->boundaryConditionPointer->setPressure(this->pressure); + this->boundaryConditionPointer->setVerticalThrottleSpeed( startSpeed, finalSpeed, time, speedIncrementUntil ); + this->boundaryConditionPointer->setHorizontalThrottleSpeed( startSpeedHThrottle, finalSpeedHThrottle, time, speedIncrementUntilHThrottle ); + /**** + * Bind DOFs + */ + this->conservativeVariables->bind( this->getMesh(), dofs ); +// this->conservativeVariables->getDensity()->write( "density", "gnuplot" ); +// this->conservativeVariables->getEnergy()->write( "energy", "gnuplot" ); +// this->conservativeVariables->getMomentum()->write( "momentum", "gnuplot", 0.05 ); +// dofs->save("dofs.tnl"); +// getchar(); +// std::cout <<"applyBCC" << std::endl; + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getDensity() ); + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 0 ] ); // uRhoVelocityX, + if( Dimensions > 1 ) + { + + this->explicitUpdaterMomentumY.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 1 ] ); // uRhoVelocityX, + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 2 ] ); // uRhoVelocityX, + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getEnergy() ); // uRhoVelocityX, + + /**** + * Turbulent energy equation + */ + this->explicitUpdaterTurbulentEnergy.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getTurbulentEnergy() ); // uRhoVelocityX, + +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +void +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + Matrix& matrix, + DofVectorPointer& b ) +{ +/* LinearSystemAssembler< Mesh, + MeshFunctionType, + InviscidOperators, + BoundaryCondition, + RightHandSide, + BackwardTimeDiscretisation, + Matrix, + DofVectorType > systemAssembler; + + MeshFunction< Mesh > u( mesh, _u ); + systemAssembler.template assembly< typename Mesh::Cell >( time, + tau, + this->differentialOperator, + this->boundaryCondition, + this->rightHandSide, + u, + matrix, + b );*/ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +oneEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ) +{ + /* + typedef typename MeshType::Cell Cell; + int count = mesh->template getEntitiesCount< Cell >()/4; + //bind _u + this->_uRho.bind( *dofs, 0, count); + this->_uRhoVelocityX.bind( *dofs, count, count); + this->_uRhoVelocityY.bind( *dofs, 2 * count, count); + this->_uEnergy.bind( *dofs, 3 * count, count); + + MeshFunctionType velocity( mesh, this->velocity ); + MeshFunctionType velocityX( mesh, this->velocityX ); + MeshFunctionType velocityY( mesh, this->velocityY ); + MeshFunctionType pressure( mesh, this->pressure ); + MeshFunctionType uRho( mesh, _uRho ); + MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); + MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); + MeshFunctionType uEnergy( mesh, _uEnergy ); + //Generating differential operators + Velocity euler2DVelocity; + VelocityX euler2DVelocityX; + VelocityY euler2DVelocityY; + Pressure euler2DPressure; + + //velocityX + euler2DVelocityX.setRhoVelX(uRhoVelocityX); + euler2DVelocityX.setRho(uRho); +// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; +// velocityX = OFVelocityX; + + //velocityY + euler2DVelocityY.setRhoVelY(uRhoVelocityY); + euler2DVelocityY.setRho(uRho); +// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; +// velocityY = OFVelocityY; + + //velocity + euler2DVelocity.setVelX(velocityX); + euler2DVelocity.setVelY(velocityY); +// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; +// velocity = OFVelocity; + + //pressure + euler2DPressure.setGamma(gamma); + euler2DPressure.setVelocity(velocity); + euler2DPressure.setEnergy(uEnergy); + euler2DPressure.setRho(uRho); +// OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure; +// pressure = OFPressure; + */ + return true; +} + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.cpp b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.cpp new file mode 100644 index 000000000..c436b1a67 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.cpp @@ -0,0 +1 @@ +#include "oneEquationTurbulenceModelStegerWarming.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.cu b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.cu new file mode 100644 index 000000000..c436b1a67 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.cu @@ -0,0 +1 @@ +#include "oneEquationTurbulenceModelStegerWarming.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.h new file mode 100644 index 000000000..4df2195b0 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.h @@ -0,0 +1,142 @@ +//#include +#include +#include +#include +#include +#include +#include "oneEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/One-Equation-Turbulence-Model/Steger-Warming/StegerWarming.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class oneEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "characteristic-length", "Value of characteristic mixing length", 1.0 ); + config.addEntry< double >( "viscosity-constant", "Value of viscosity constant", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); + typedef Meshes::Grid< 3 > Mesh; + StegerWarming< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class oneEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef PrandtlKolmogorovOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< oneEquationTurbulenceModelSetter, oneEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.cpp b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.cpp new file mode 100644 index 000000000..84d001692 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.cpp @@ -0,0 +1 @@ +#include "oneEquationTurbulenceModelVanLeer.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.cu b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.cu new file mode 100644 index 000000000..0b4d7cae1 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.cu @@ -0,0 +1 @@ +#include "oneEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h new file mode 100644 index 000000000..eec8a4bf1 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h @@ -0,0 +1,138 @@ +//#include +#include +#include +#include +#include +#include +#include "oneEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/One-Equation-Turbulence-Model/VanLeer/VanLeer.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class oneEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + VanLeer< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class oneEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef PrandtlKolmogorovOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef oneEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< oneEquationTurbulenceModelSetter, oneEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model b/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model new file mode 100644 index 000000000..cd0c1bbb1 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-euler-navier-stokes + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --differential-operator Steger-Warming \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-AUSM-plus b/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-AUSM-plus new file mode 100644 index 000000000..faaad26b4 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-AUSM-plus @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Ausm-Plus + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Lax-Friedrichs b/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Lax-Friedrichs new file mode 100644 index 000000000..5f7bfbdc6 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Lax-Friedrichs @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Lax-Friedrichs + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Steger-Warming b/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Steger-Warming new file mode 100644 index 000000000..1c3b5ba65 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Steger-Warming @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Steger-Warming + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Van-Leer b/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Van-Leer new file mode 100644 index 000000000..1c3b5ba65 --- /dev/null +++ b/src/Examples/turbulent-flows/one-equation-model/run-one-equation-turbulence-model-Van-Leer @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Steger-Warming + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/two-equation-model/CMakeLists.txt b/src/Examples/turbulent-flows/two-equation-model/CMakeLists.txt new file mode 100644 index 000000000..982eff3f3 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory( KEPsilon-model ) +add_subdirectory( KOmega-model ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h new file mode 100644 index 000000000..0709bc3b9 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h @@ -0,0 +1,190 @@ +#include + +#include "DensityBoundaryConditionBoiler.h" +#include "MomentumXBoundaryConditionBoiler.h" +#include "MomentumYBoundaryConditionBoiler.h" +#include "MomentumZBoundaryConditionBoiler.h" +#include "EnergyBoundaryConditionBoiler.h" +#include "TurbulentEnergyBoundaryConditionBoiler.h" +#include "DisipationBoundaryConditionBoiler.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsBoiler +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::TurbulentEnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef TNL::Operators::DisipationBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > DisipationBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< DisipationBoundaryConditionsType > DisipationBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->disipationBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->turbulentEnergyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->disipationBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + } + + void setIntensity(const RealType& intensity) + { + this->turbulentEnergyBoundaryConditionsPointer->setIntensity( intensity ); + this->disipationBoundaryConditionsPointer->setIntensity( intensity ); + } + + void setLengthScale( const RealType& lengthScale ) + { + this->disipationBoundaryConditionsPointer->setLengthScale ( lengthScale ); + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->disipationBoundaryConditionsPointer->setTurbulenceConstant ( turbulenceConstant ); + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + DisipationBoundaryConditionsTypePointer& getDisipationBoundaryCondition() + { + return this->disipationBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + DisipationBoundaryConditionsTypePointer disipationBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h new file mode 100644 index 000000000..6231f6780 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h @@ -0,0 +1,542 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().y() < 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().z() < 0.8 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionBoilers: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h new file mode 100644 index 000000000..a94af83b6 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h @@ -0,0 +1,718 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DisipationBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function> +class DisipationBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DisipationBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h new file mode 100644 index 000000000..412640b54 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h @@ -0,0 +1,853 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + + + this->cavitySpeed + * + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) +{ + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * + ( + ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( + this->cavitySpeed + * + this->cavitySpeed + ) + ); + + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h new file mode 100644 index 000000000..dfe63e076 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h @@ -0,0 +1,594 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h new file mode 100644 index 000000000..83b6282dd --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h @@ -0,0 +1,588 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h new file mode 100644 index 000000000..9d887857c --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h @@ -0,0 +1,563 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h new file mode 100644 index 000000000..e6b63da71 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h @@ -0,0 +1,664 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class TurbulentEnergyBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function> +class TurbulentEnergyBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const TurbulentEnergyBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h new file mode 100644 index 000000000..44e2b9531 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h @@ -0,0 +1,237 @@ +#include + +#include "DensityBoundaryConditionBoilerModel.h" +#include "MomentumXBoundaryConditionBoilerModel.h" +#include "MomentumYBoundaryConditionBoilerModel.h" +#include "MomentumZBoundaryConditionBoilerModel.h" +#include "EnergyBoundaryConditionBoilerModel.h" +#include "TurbulentEnergyBoundaryConditionBoilerModel.h" +#include "DisipationBoundaryConditionBoilerModel.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsBoilerModel +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef TNL::Operators::DisipationBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > DisipationBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< DisipationBoundaryConditionsType > DisipationBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "vertical-angle", "Vertical angle of throttle in degrees", 0 ); + config.addEntry< double >( prefix + "horizontal-angle", "Horizontal angle of throttle in degrees", 45 ); + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + setZAngle(parameters.getParameter< double >( prefix + "vertical-angle" ) * M_PI / 180.0 ); + setXYAngle(parameters.getParameter< double >( prefix + "horizontal-angle" ) * M_PI / 180.0 ); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->turbulentEnergyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->disipationBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setZAngle(const RealType zAngle) + { + this->densityBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumXBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumYBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumZBoundaryConditionsPointer->setZAngle(zAngle); + this->energyBoundaryConditionsPointer->setZAngle(zAngle); + this->turbulentEnergyBoundaryConditionsPointer->setZAngle(zAngle); + this->disipationBoundaryConditionsPointer->setZAngle(zAngle); + } + + void setXYAngle(const RealType xYAngle) + { + this->densityBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumXBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumYBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumZBoundaryConditionsPointer->setXYAngle(xYAngle); + this->turbulentEnergyBoundaryConditionsPointer->setXYAngle(xYAngle); + this->disipationBoundaryConditionsPointer->setXYAngle(xYAngle); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setIntensity(const RealType& intensity) + { + this->turbulentEnergyBoundaryConditionsPointer->setIntensity( intensity ); + this->disipationBoundaryConditionsPointer->setIntensity( intensity ); + } + + void setLengthScale( const RealType& lengthScale ) + { + this->disipationBoundaryConditionsPointer->setLengthScale ( lengthScale ); + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->disipationBoundaryConditionsPointer->setTurbulenceConstant ( turbulenceConstant ); + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + RealType horizontalThrottleSpeed = 0; + if(time <= finalTime) + if( time != 0 && finalTime != 0 ) + horizontalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) * ( time / finalTime ); + else + horizontalThrottleSpeed = 0; + else + horizontalThrottleSpeed = finalSpeed; + this->momentumXBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->momentumYBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->momentumZBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->energyBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->turbulentEnergyBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->disipationBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + RealType verticalThrottleSpeed = 0; + if(time <= finalTime) + if( time != 0 && finalTime != 0 ) + verticalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) * ( time / finalTime ); + else + verticalThrottleSpeed = 0; + else + verticalThrottleSpeed = finalSpeed; + this->momentumXBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->momentumYBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->momentumZBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->energyBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->turbulentEnergyBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->disipationBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + DisipationBoundaryConditionsTypePointer& getDisipationBoundaryCondition() + { + return this->disipationBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + DisipationBoundaryConditionsTypePointer disipationBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..a58f32f7c --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h @@ -0,0 +1,580 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().y() < 0.835 * ( entity.getMesh().getDimensions().y() - 1 )) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + // if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..b3f585a9e --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h @@ -0,0 +1,892 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DisipationBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function> +class DisipationBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle Disipation + { + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + }; + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle Disipation + { + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + } +// if for chimney exit + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ +const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; +// if for chimney exit + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) +// &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DisipationBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..d0475576b --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h @@ -0,0 +1,962 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle energy + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + }; + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle energy + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + if( (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] != 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * ( ( (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + ) + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + ); + else return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->verticalThrottleSpeed + * + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ +const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; +// if for chimney exit + } + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + if( (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] != 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * ( ( (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 2 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 2 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + ) + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + ); + else return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) +// &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->verticalThrottleSpeed + * + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..65648c389 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -0,0 +1,940 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +//throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->zAngle ) + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->zAngle ) + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..e8aa33e88 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h @@ -0,0 +1,941 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +//throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( - 1.0 ) + * std::sin( this->zAngle ) + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) +// down throttle + { + if( + ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) + ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->verticalThrottleSpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..625b74585 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -0,0 +1,838 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( + ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..851b70618 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h @@ -0,0 +1,832 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class TurbulentEnergyBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function> +class TurbulentEnergyBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle TurbulentEnergy + { + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + }; + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle TurbulentEnergy + { + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + } +// if for chimney exit + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ +const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed;; + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; +// if for chimney exit + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed;; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) +// &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed;; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const TurbulentEnergyBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h new file mode 100644 index 000000000..e2adc7424 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h @@ -0,0 +1,193 @@ +#include + +#include "DensityBoundaryConditionCavity.h" +#include "MomentumXBoundaryConditionCavity.h" +#include "MomentumYBoundaryConditionCavity.h" +#include "MomentumZBoundaryConditionCavity.h" +#include "EnergyBoundaryConditionCavity.h" +#include "TurbulentEnergyBoundaryConditionCavity.h" +#include "DisipationBoundaryConditionCavity.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsCavity +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::TurbulentEnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef TNL::Operators::DisipationBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > DisipationBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< DisipationBoundaryConditionsType > DisipationBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->turbulentEnergyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->disipationBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->turbulentEnergyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->disipationBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->turbulentEnergyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->disipationBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + } + + void setIntensity(const RealType& intensity) + { + this->turbulentEnergyBoundaryConditionsPointer->setIntensity( intensity ); + this->disipationBoundaryConditionsPointer->setIntensity( intensity ); + } + + void setLengthScale( const RealType& lengthScale ) + { + this->disipationBoundaryConditionsPointer->setLengthScale ( lengthScale ); + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->disipationBoundaryConditionsPointer->setTurbulenceConstant ( turbulenceConstant ); + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + DisipationBoundaryConditionsTypePointer& getDisipationBoundaryCondition() + { + return this->disipationBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + DisipationBoundaryConditionsTypePointer disipationBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h new file mode 100644 index 000000000..c753d324a --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h @@ -0,0 +1,536 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 1, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 1 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h new file mode 100644 index 000000000..acee185a2 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h @@ -0,0 +1,610 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DisipationBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function> +class DisipationBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DisipationBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h new file mode 100644 index 000000000..ca5d85442 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h @@ -0,0 +1,672 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< 1, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< -1, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + ); + } + if( entity.getCoordinates().y() == 0 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 1 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + ); + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, -1 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + * ( + this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + * + this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + * + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h new file mode 100644 index 000000000..07abfdbeb --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h @@ -0,0 +1,570 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + * ( + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + ); + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h new file mode 100644 index 000000000..a83dd653f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h @@ -0,0 +1,564 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h new file mode 100644 index 000000000..5fe6f22e5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h @@ -0,0 +1,554 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h new file mode 100644 index 000000000..05098c7dd --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h @@ -0,0 +1,568 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class TurbulentEnergyBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function> +class TurbulentEnergyBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const TurbulentEnergyBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h new file mode 100644 index 000000000..8a93fd2fc --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h @@ -0,0 +1,159 @@ +#include +#include +#include +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Function = Functions::Analytic::Constant< Mesh::getMeshDimension(), typename Mesh::RealType >, + int MeshEntitiesDimension = Mesh::getMeshDimension(), + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class BoundaryConditionsDirichlet +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > DisipationBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< DisipationBoundaryConditionsType > DisipationBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + + } + + void setTimestep(const RealType timestep) + { + + } + + void setGamma(const RealType gamma) + { + + } + + void setPressure(const MeshFunctionPointer& pressure) + { + + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setIntensity(const RealType& intensity) + { + + } + + void setLengthScale( const RealType& lengthScale ) + { + + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + DisipationBoundaryConditionsTypePointer& getDisipationBoundaryCondition() + { + return this->disipationBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + DisipationBoundaryConditionsTypePointer disipationBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h new file mode 100644 index 000000000..bc6c4bdec --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h @@ -0,0 +1,155 @@ +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class BoundaryConditionsNeumann +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > DisipationBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< DisipationBoundaryConditionsType > DisipationBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + + } + + void setTimestep(const RealType timestep) + { + + } + + void setGamma(const RealType gamma) + { + + } + + void setPressure(const MeshFunctionPointer& pressure) + { + + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setIntensity(const RealType& intensity) + { + + } + + void setLengthScale( const RealType& lengthScale ) + { + + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + DisipationBoundaryConditionsTypePointer& getDisipationBoundaryCondition() + { + return this->disipationBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + DisipationBoundaryConditionsTypePointer disipationBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists.txt b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists.txt new file mode 100644 index 000000000..950d69b32 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists.txt @@ -0,0 +1,101 @@ +#k-epsilon-Lax-Friedrichs + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + twoEquationTurbulenceModelLaxFriedrichs.cpp + twoEquationTurbulenceModelLaxFriedrichs.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-k-epsilon-Lax-Friedrichs twoEquationTurbulenceModelLaxFriedrichs.cu) + target_link_libraries (tnl-k-epsilon-Lax-Friedrichs ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-k-epsilon-Lax-Friedrichs twoEquationTurbulenceModelLaxFriedrichs.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-k-epsilon-Lax-Friedrichs + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-two-equation-turbulence-model-Lax-Friedrichs + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#k-epsilon-Steger-Warming + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + twoEquationTurbulenceModelStegerWarming.cpp + twoEquationTurbulenceModelStegerWarming.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-k-epsilon-Steger-Warming twoEquationTurbulenceModelStegerWarming.cu) + target_link_libraries (tnl-k-epsilon-Steger-Warming ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-k-epsilon-Steger-Warming twoEquationTurbulenceModelStegerWarming.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-k-epsilon-Steger-Warming + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-two-equation-turbulence-model-Steger-Warming + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#k-epsilon-Van-Leer + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + twoEquationTurbulenceModelVanLeer.cpp + twoEquationTurbulenceModelVanLeer.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-k-epsilon-Van-Leer twoEquationTurbulenceModelVanLeer.cu) + target_link_libraries (tnl-k-epsilon-Van-Leer ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-k-epsilon-Van-Leer twoEquationTurbulenceModelVanLeer.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-k-epsilon-Van-Leer + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-two-equation-turbulence-model-Van-Leer + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#k-epsilon-AUSM-plus + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + twoEquationTurbulenceModelAUSMPlus.cpp + twoEquationTurbulenceModelAUSMPlus.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-k-epsilon-AUSM-plus twoEquationTurbulenceModelAUSMPlus.cu) + target_link_libraries (tnl-k-epsilon-AUSM-plus ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-k-epsilon-AUSM-plus twoEquationTurbulenceModelAUSMPlus.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-k-epsilon-AUSM-plus + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-two-equation-turbulence-model-AUSM-plus + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists_separate.txt b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists_separate.txt new file mode 100644 index 000000000..cd8e6f870 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists_separate.txt @@ -0,0 +1,101 @@ +#navier-stokes-Lax-Friedrichs + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesLaxFriedrichs.cpp + navierStokesLaxFriedrichs.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cu) + target_link_libraries (tnl-navier-stokes-Lax-Friedrichs ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Lax-Friedrichs + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Lax-Friedrichs + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Steger-Warming + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesStegerWarming.cpp + navierStokesStegerWarming.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cu) + target_link_libraries (tnl-navier-stokes-Steger-Warming ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Steger-Warming + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Steger-Warming + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Van-Leer + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesVanLeer.cpp + navierStokesVanLeer.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cu) + target_link_libraries (tnl-navier-stokes-Van-Leer ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Van-Leer + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Van-Leer + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-AUSM-plus + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesAUSMPlus.cpp + navierStokesAUSMPlus.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cu) + target_link_libraries (tnl-navier-stokes-AUSM-plus ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-AUSM-plus + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-AUSM-plus + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists_together.txt b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists_together.txt new file mode 100644 index 000000000..f26fc6d34 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CMakeLists_together.txt @@ -0,0 +1,26 @@ +#navier-stokes + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokes.cpp + navierStokes.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cu) + target_link_libraries (tnl-navier-stokes ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CompressibleConservativeVariables.h new file mode 100644 index 000000000..a6c4a7591 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/CompressibleConservativeVariables.h @@ -0,0 +1,202 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ), + turbulentEnergy( meshPointer ), + disipation( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + this->turbulentEnergy->setMesh( meshPointer ); + this->disipation->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + currentOffset += this->energy->getDofs( meshPointer ); + this->turbulentEnergy->bind( meshPointer, data, currentOffset ); + currentOffset += this->turbulentEnergy->getDofs( meshPointer ); + this->disipation->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ) + + this->turbulentEnergy->getDofs( meshPointer ) + + this->disipation->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + __cuda_callable__ + MeshFunctionPointer& getTurbulentEnergy() + { + return this->turbulentEnergy; + } + + __cuda_callable__ + const MeshFunctionPointer& getTurbulentEnergy() const + { + return this->turbulentEnergy; + } + + void setTurbulentEnergy( MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + __cuda_callable__ + MeshFunctionPointer& getDisipation() + { + return this->disipation; + } + + __cuda_callable__ + const MeshFunctionPointer& getDisipation() const + { + return this->disipation; + } + + void setDisipation( MeshFunctionPointer& disipation ) + { + this->disipation = disipation; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + MeshFunctionPointer turbulentEnergy; + MeshFunctionPointer disipation; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h new file mode 100644 index 000000000..871edff20 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h @@ -0,0 +1,246 @@ +/*************************************************************************** + AUSMPlus.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "AUSMPlusContinuity.h" +#include "AUSMPlusEnergy.h" +#include "AUSMPlusMomentumX.h" +#include "AUSMPlusMomentumY.h" +#include "AUSMPlusMomentumZ.h" +#include "AUSMPlusTurbulentEnergy.h" +#include "AUSMPlusDisipation.h" + +#include "Examples/turbulent-flows/two-equation-model/KEpsilon-model/DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = KEpsilonOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlus +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::DisipationOperatorRightHandSideType DisipationOperatorRightHandSideType; + + typedef AUSMPlusContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef AUSMPlusMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef AUSMPlusMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef AUSMPlusMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef AUSMPlusEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef AUSMPlusTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + typedef AUSMPlusDisipation< Mesh, DisipationOperatorRightHandSideType, Real, Index > DisipationOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + typedef Pointers::SharedPointer< DisipationOperatorType > DisipationOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + AUSMPlus() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "AUSMPlus" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->disipationOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + this->disipationOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + this->turbulentEnergyOperatorPointer->setGamma( gamma ); + this->disipationOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + this->turbulentEnergyOperatorPointer->setPressure( pressure ); + this->disipationOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + this->turbulentEnergyOperatorPointer->setDensity( density ); + this->disipationOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + this->disipationOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->disipationOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->disipationOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + void setViscosityConstant1( const RealType& viscosityConstant1 ) + { + this->disipationOperatorPointer->setViscosityConstant1( viscosityConstant1 ); + } + + void setViscosityConstant2( const RealType& viscosityConstant2 ) + { + this->disipationOperatorPointer->setViscosityConstant2( viscosityConstant2 ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->disipationOperatorPointer->setSigmaEpsilon( sigmaEpsilon ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->disipationOperatorPointer->setDisipation( disipation ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + const DisipationOperatorPointer& getDisipationOperator() const + { + return this->disipationOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + DisipationOperatorPointer disipationOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h new file mode 100644 index 000000000..2d92e9dc8 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h @@ -0,0 +1,401 @@ +/*************************************************************************** + AUSMPlusContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "AUSMPlusContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType DensityFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity + MachBorderMinus * RightDensity ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return hxInverse * ( + this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return hxInverse * ( + this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->DensityFlux( u[ north ], u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) + - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return hxInverse * ( + this->DensityFlux( u[ west ] , u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->DensityFlux( u[ north ] , u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) + - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + ) + + hzInverse * ( + this->DensityFlux( u[ up ] , u[ center ], velocity_z_up , velocity_z_center, pressure_up , pressure_center ) + - this->DensityFlux( u[ center ], u[ down ] , velocity_z_center, velocity_z_down , pressure_center, pressure_down ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h new file mode 100644 index 000000000..d6ca3d7fa --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h @@ -0,0 +1,465 @@ +/*************************************************************************** + AUSMPlusDisipation.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusDisipationBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "AUSMPlusDisipation< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity( velocity ); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + this->rightHandSide.setDensity( density ); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity( turbulentViscosity ); + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity( dynamicalViscosity ); + } + + void setViscosityConstant1( const RealType& viscosityConstant1 ) + { + this->rightHandSide.setViscosityConstant1( viscosityConstant1 ); + } + + void setViscosityConstant2( const RealType& viscosityConstant2 ) + { + this->rightHandSide.setViscosityConstant2( viscosityConstant2 ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->rightHandSide.setSigmaEpsilon( sigmaEpsilon ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy( turbulentEnergy ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + } + + RealType DisipationFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure, + const RealType& LeftDisipation, + const RealType& RightDisipation ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDisipation + MachBorderMinus * RightDisipation ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusDisipation +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusDisipation< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusDisipationBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return hxInverse * ( + this->DisipationFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->DisipationFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusDisipation< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusDisipationBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return hxInverse * ( + this->DisipationFlux( density_west , density_center , velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->DisipationFlux( density_center , density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->DisipationFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ], u[ center ] ) + - this->DisipationFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusDisipation< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusDisipationBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return hxInverse * ( + this->DisipationFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ] , u[ center ] ) + - this->DisipationFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->DisipationFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ] , u[ center ] ) + - this->TurbulrntEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + ) + + hzInverse * ( + this->DisipationFlux( density_up , density_center, velocity_z_up , velocity_z_center, pressure_up , pressure_center, u[ up ] , u[ center ]) + - this->DisipationFlux( density_center, density_down , velocity_z_center, velocity_z_down , pressure_center, pressure_down , u[ center ], u[ down ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h new file mode 100644 index 000000000..fa7b33b42 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h @@ -0,0 +1,521 @@ +/*************************************************************************** + AUSMPlusEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + AUSMPlusEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "AUSMPlusEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + RealType EnergyFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure, + const RealType& LeftEnergy, + const RealType& RightEnergy ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * ( LeftEnergy + LeftPressure) + MachBorderMinus * ( RightEnergy + RightPressure ) ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->EnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->EnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->EnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->EnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + ) + + hzInverse * ( + this->EnergyFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ], u[ center ] ) + - this->EnergyFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h new file mode 100644 index 000000000..a65ba0174 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h @@ -0,0 +1,205 @@ +/*************************************************************************** + AUSMPlusMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + RealType MainMomentumFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + RealType PressureSplitingPlus = 0; + RealType PressureSplitingMinus = 0; + RealType PressureBorder = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + PressureSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + PressureSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) * (2.0 - LeftMachNumber ) + + 3.0 / 16.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + PressureSplitingPlus = 1.0; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + PressureSplitingMinus = 1.0; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) * (2.0 + RightMachNumber ) + - 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + PressureSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + PressureBorder = PressureSplitingPlus * LeftPressure + PressureSplitingMinus * RightPressure; + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity * LeftVelocity + MachBorderMinus * RightDensity * RightVelocity ) + PressureBorder; + } + + RealType OtherMomentumFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftOtherVelocity, + const RealType& RightOtherVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity * LeftOtherVelocity + MachBorderMinus * RightDensity * RightOtherVelocity ); + } + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType dynamicalViscosity; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h new file mode 100644 index 000000000..1468cf891 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h @@ -0,0 +1,398 @@ +/*************************************************************************** + AUSMPlusMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->OtherMomentumFlux( density_down , density_center, velocity_x_down , velocity_x_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->OtherMomentumFlux( density_center, density_up , velocity_x_center, velocity_x_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h new file mode 100644 index 000000000..d1a8d4304 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h @@ -0,0 +1,371 @@ +/*************************************************************************** + AUSMPlusMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->OtherMomentumFlux( density_down , density_center, velocity_y_down , velocity_y_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->OtherMomentumFlux( density_center, density_up , velocity_y_center, velocity_y_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h new file mode 100644 index 000000000..fcc6183f2 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h @@ -0,0 +1,316 @@ +/*************************************************************************** + AUSMPlusMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_z_west , velocity_z_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_z_center, velocity_z_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_z_south , velocity_z_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->MainMomentumFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->MainMomentumFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h new file mode 100644 index 000000000..ed24d118b --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h @@ -0,0 +1,449 @@ +/*************************************************************************** + AUSMPlusTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "AUSMPlusTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + } + + RealType TurbulentEnergyFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure, + const RealType& LeftTurbulentEnergy, + const RealType& RightTurbulentEnergy ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftTurbulentEnergy + MachBorderMinus * RightTurbulentEnergy ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return hxInverse * ( + this->TurbulentEnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return hxInverse * ( + this->TurbulentEnergyFlux( density_west , density_center , velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center , density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return hxInverse * ( + this->TurbulentEnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ] , u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ] , u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + ) + + hzInverse * ( + this->TurbulentEnergyFlux( density_up , density_center, velocity_z_up , velocity_z_center, pressure_up , pressure_center, u[ up ] , u[ center ]) + - this->TurbulentEnergyFlux( density_center, density_down , velocity_z_center, velocity_z_down , pressure_center, pressure_down , u[ center ], u[ down ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h new file mode 100644 index 000000000..be4d84528 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h @@ -0,0 +1,244 @@ +/*************************************************************************** + LaxFridrichs.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "LaxFridrichsContinuity.h" +#include "LaxFridrichsEnergy.h" +#include "LaxFridrichsMomentumX.h" +#include "LaxFridrichsMomentumY.h" +#include "LaxFridrichsMomentumZ.h" +#include "LaxFridrichsTurbulentEnergy.h" +#include "LaxFridrichsDisipation.h" + +#include "Examples/turbulent-flows/two-equation-model/KEpsilon-model/DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = KEpsilonOperatorRightHandSide< Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichs +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::DisipationOperatorRightHandSideType DisipationOperatorRightHandSideType; + + typedef LaxFridrichsContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef LaxFridrichsMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef LaxFridrichsMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef LaxFridrichsMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef LaxFridrichsEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef LaxFridrichsTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + typedef LaxFridrichsDisipation< Mesh, DisipationOperatorRightHandSideType, Real, Index > DisipationOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + typedef Pointers::SharedPointer< DisipationOperatorType > DisipationOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + LaxFridrichs() + : artificialViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "Lax-Friedrichs" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->disipationOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); + this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->turbulentEnergyOperatorPointer->setArtificialViscosity( artificialViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + this->disipationOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + this->disipationOperatorPointer->setVelocity( velocity ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->disipationOperatorPointer->setDensity( density ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->disipationOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setCharacteristicLength( RealType& characteristicLength ) + { + this->turbulentEnergyOperatorPointer->setCharacteristicLength( characteristicLength ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->disipationOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + void setViscosityConstant1( const RealType& viscosityConstant1 ) + { + this->disipationOperatorPointer->setViscosityConstant1( viscosityConstant1 ); + } + + void setViscosityConstant2( const RealType& viscosityConstant2 ) + { + this->disipationOperatorPointer->setViscosityConstant2( viscosityConstant2 ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->disipationOperatorPointer->setSigmaEpsilon( sigmaEpsilon ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->disipationOperatorPointer->setDisipation( disipation ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + const DisipationOperatorPointer& getDisipationOperator() const + { + return this->disipationOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + DisipationOperatorPointer disipationOperatorPointer; + + RealType artificialViscosity; + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h new file mode 100644 index 000000000..e82c9d424 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h @@ -0,0 +1,310 @@ +/*************************************************************************** + LaxFridrichsContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsContinuityBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + RealType artificialViscosity; +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + +// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) +// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsDisipation.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsDisipation.h new file mode 100644 index 000000000..c001b847c --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsDisipation.h @@ -0,0 +1,352 @@ +/*************************************************************************** + LaxFridrichsDisipation.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsDisipationBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsDisipationBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsDisipation< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity( velocity ); + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->rightHandSide.setDensity( density ); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity( turbulentViscosity ); + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity( dynamicalViscosity ); + } + + void setViscosityConstant1( const RealType& viscosityConstant1 ) + { + this->rightHandSide.setViscosityConstant1( viscosityConstant1 ); + } + + void setViscosityConstant2( const RealType& viscosityConstant2 ) + { + this->rightHandSide.setViscosityConstant2( viscosityConstant2 ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->rightHandSide.setSigmaEpsilon( sigmaEpsilon ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy( turbulentEnergy ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + } + + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + RealType artificialViscosity; +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsDisipation +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsDisipation< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsDisipationBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + +// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) +// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsDisipation< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsDisipationBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsDisipation< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsDisipationBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h new file mode 100644 index 000000000..16256aa80 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -0,0 +1,349 @@ +/*************************************************************************** + LaxFridrichsEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) + - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east + - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ) + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse + + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) + -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ) + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h new file mode 100644 index 000000000..cde9e58c8 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -0,0 +1,88 @@ +/*************************************************************************** + LaxFridrichsMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsMomentumBase() + : artificialViscosity( 1.0 ){}; + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + } + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h new file mode 100644 index 000000000..57258d1a5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h @@ -0,0 +1,295 @@ +/*************************************************************************** + LaxFridrichsMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) + - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ) + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_u[ up ] * velocity_z_up ) + - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ) + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h new file mode 100644 index 000000000..4cca02779 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h @@ -0,0 +1,280 @@ +/*************************************************************************** + LaxFridrichsMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ) + + + this->rightHandSide(rho_v, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse + + ( ( rho_v[ up ] * velocity_z_up ) + - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ) + + + this->rightHandSide(rho_v, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h new file mode 100644 index 000000000..1f394bfef --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h @@ -0,0 +1,251 @@ +/*************************************************************************** + LaxFridrichsMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) + -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) + - ( rho_w[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_w[ north ] * velocity_y_north ) + - ( rho_w[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) + - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ) + + + this->rightHandSide(rho_w, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h new file mode 100644 index 000000000..02c03dffa --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h @@ -0,0 +1,342 @@ +/*************************************************************************** + LaxFridrichsTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsTurbulentEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setCharacteristicLength( RealType& characteristicLength ) + { + this->rightHandSide.setCharacteristicLength( characteristicLength ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + } + + void setViscosityConstant( RealType& ViscosityConstant ) + { + this->rightHandSide.setViscosityConstant( ViscosityConstant ); + } + + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + RealType artificialViscosity; +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + +// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) +// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h new file mode 100644 index 000000000..5575bf5ac --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h @@ -0,0 +1,247 @@ +/*************************************************************************** + StegerWarming.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "StegerWarmingContinuity.h" +#include "StegerWarmingEnergy.h" +#include "StegerWarmingMomentumX.h" +#include "StegerWarmingMomentumY.h" +#include "StegerWarmingMomentumZ.h" +#include "StegerWarmingTurbulentEnergy.h" +#include "StegerWarmingDisipation.h" + +#include "Examples/turbulent-flows/two-equation-model/KEpsilon-model/DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = KEpsilonOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarming +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::DisipationOperatorRightHandSideType DisipationOperatorRightHandSideType; + + + typedef StegerWarmingContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef StegerWarmingMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef StegerWarmingMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef StegerWarmingMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef StegerWarmingEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef StegerWarmingTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + typedef StegerWarmingDisipation< Mesh, DisipationOperatorRightHandSideType, Real, Index > DisipationOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + typedef Pointers::SharedPointer< DisipationOperatorType > DisipationOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + StegerWarming() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "Steger-Warming"<< std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->disipationOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + this->disipationOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + this->turbulentEnergyOperatorPointer->setGamma( gamma ); + this->disipationOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + this->turbulentEnergyOperatorPointer->setPressure( pressure ); + this->disipationOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + this->turbulentEnergyOperatorPointer->setDensity( density ); + this->disipationOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + this->disipationOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->disipationOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->disipationOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + void setViscosityConstant1( const RealType& viscosityConstant1 ) + { + this->disipationOperatorPointer->setViscosityConstant1( viscosityConstant1 ); + } + + void setViscosityConstant2( const RealType& viscosityConstant2 ) + { + this->disipationOperatorPointer->setViscosityConstant2( viscosityConstant2 ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->disipationOperatorPointer->setSigmaEpsilon( sigmaEpsilon ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->disipationOperatorPointer->setDisipation( disipation ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + const DisipationOperatorPointer& getDisipationOperator() const + { + return this->disipationOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + DisipationOperatorPointer disipationOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h new file mode 100644 index 000000000..5fbef7be6 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h @@ -0,0 +1,396 @@ +/*************************************************************************** + StegerWarmingContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingDisipation.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingDisipation.h new file mode 100644 index 000000000..e93fc3947 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingDisipation.h @@ -0,0 +1,458 @@ +/*************************************************************************** + StegerWarmingDisipation.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingDisipationBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingDisipation< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity( velocity ); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + this->rightHandSide.setDensity( density ); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity( turbulentViscosity ); + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity( dynamicalViscosity ); + } + + void setViscosityConstant1( const RealType& viscosityConstant1 ) + { + this->rightHandSide.setViscosityConstant1( viscosityConstant1 ); + } + + void setViscosityConstant2( const RealType& viscosityConstant2 ) + { + this->rightHandSide.setViscosityConstant2( viscosityConstant2 ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->rightHandSide.setSigmaEpsilon( sigmaEpsilon ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy( turbulentEnergy ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + } + + RealType positiveDisipationFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& disipation ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return disipation * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); + else if ( machNumber <= 1.0 ) + return disipation * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); + else + return disipation * velocity; + }; + + RealType negativeDisipationFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& disipation ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return disipation * velocity; + else if ( machNumber <= 0.0 ) + return disipation * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); + else if ( machNumber <= 1.0 ) + return disipation * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingDisipation +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingDisipation< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingDisipationBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingDisipation< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingDisipationBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingDisipation< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingDisipationBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + -hzInverse * ( + this->positiveDisipationFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_down , velocity_z_down , pressure_down , u[ down ] ) + - this->negativeDisipationFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_up , velocity_z_up , pressure_up , u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h new file mode 100644 index 000000000..f51bf7e53 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h @@ -0,0 +1,560 @@ +/*************************************************************************** + StegerWarmingEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hzInverse * ( + this->positiveEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_z_down , velocity_x_down , velocity_y_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_z_up , velocity_x_up , velocity_y_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h new file mode 100644 index 000000000..e6c6c1fbb --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h @@ -0,0 +1,150 @@ +/*************************************************************************** + StegerWarmingMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + } + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber + 1.0 ) * ( machNumber + 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber + 1.0 ) * (machNumber + 1.0 ) ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber - 1.0 ) * (machNumber - 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber - 1.0 ) * ( machNumber - 1.0 ) ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h new file mode 100644 index 000000000..c6588083c --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h @@ -0,0 +1,356 @@ +/*************************************************************************** + StegerWarmingMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h new file mode 100644 index 000000000..210fb6087 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h @@ -0,0 +1,326 @@ +/*************************************************************************** + StegerWarmingMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h new file mode 100644 index 000000000..135352d2f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h @@ -0,0 +1,282 @@ +/*************************************************************************** + StegerWarmingMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 0-hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h new file mode 100644 index 000000000..20bff760a --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h @@ -0,0 +1,442 @@ +/*************************************************************************** + StegerWarmingTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + }; + + RealType positiveTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); + else if ( machNumber <= 1.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); + else + return turbulentEnergy * velocity; + }; + + RealType negativeTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return turbulentEnergy * velocity; + else if ( machNumber <= 0.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); + else if ( machNumber <= 1.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + -hzInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_down , velocity_z_down , pressure_down , u[ down ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_up , velocity_z_up , pressure_up , u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h new file mode 100644 index 000000000..cd0a07043 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h @@ -0,0 +1,246 @@ +/*************************************************************************** + VanLeer.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "VanLeerContinuity.h" +#include "VanLeerEnergy.h" +#include "VanLeerMomentumX.h" +#include "VanLeerMomentumY.h" +#include "VanLeerMomentumZ.h" +#include "VanLeerTurbulentEnergy.h" +#include "VanLeerDisipation.h" + +#include "Examples/turbulent-flows/two-equation-model/KEpsilon-model/DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = KEpsilonOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeer +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::DisipationOperatorRightHandSideType DisipationOperatorRightHandSideType; + + typedef VanLeerContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef VanLeerMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef VanLeerMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef VanLeerMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef VanLeerEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef VanLeerTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + typedef VanLeerDisipation< Mesh, DisipationOperatorRightHandSideType, Real, Index > DisipationOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + typedef Pointers::SharedPointer< DisipationOperatorType > DisipationOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + VanLeer() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "VanLeer" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->disipationOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + this->disipationOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + this->turbulentEnergyOperatorPointer->setGamma( gamma ); + this->disipationOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + this->turbulentEnergyOperatorPointer->setPressure( pressure ); + this->disipationOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + this->turbulentEnergyOperatorPointer->setDensity( density ); + this->disipationOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + this->disipationOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->disipationOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->disipationOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + void setViscosityConstant1( const RealType& viscosityConstant1 ) + { + this->disipationOperatorPointer->setViscosityConstant1( viscosityConstant1 ); + } + + void setViscosityConstant2( const RealType& viscosityConstant2 ) + { + this->disipationOperatorPointer->setViscosityConstant2( viscosityConstant2 ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->disipationOperatorPointer->setSigmaEpsilon( sigmaEpsilon ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->disipationOperatorPointer->setDisipation( disipation ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + const DisipationOperatorPointer& getDisipationOperator() const + { + return this->disipationOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + DisipationOperatorPointer disipationOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerContinuity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerContinuity.h new file mode 100644 index 000000000..3b497125a --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerContinuity.h @@ -0,0 +1,396 @@ +/*************************************************************************** + VanLeerContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "VanLeerContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + RealType multiply (const RealType& a, const RealType& b ) const + { + return a * b; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerDisipation.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerDisipation.h new file mode 100644 index 000000000..664790a55 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerDisipation.h @@ -0,0 +1,453 @@ +/*************************************************************************** + VanLeerDisipation.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerDisipationBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "VanLeerDisipation< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity( velocity ); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + this->rightHandSide.setDensity( density ); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity( turbulentViscosity ); + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity( dynamicalViscosity ); + } + + void setViscosityConstant1( const RealType& viscosityConstant1 ) + { + this->rightHandSide.setViscosityConstant1( viscosityConstant1 ); + } + + void setViscosityConstant2( const RealType& viscosityConstant2 ) + { + this->rightHandSide.setViscosityConstant2( viscosityConstant2 ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->rightHandSide.setSigmaEpsilon( sigmaEpsilon ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy( turbulentEnergy ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + } + + RealType positiveDisipationFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& disipation ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return disipation * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); + else + return disipation * velocity; + }; + + RealType negativeDisipationFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& disipation ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return disipation * velocity; + else if ( machNumber <= 1.0 ) + return - disipation * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerDisipation +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerDisipation< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerDisipationBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerDisipation< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerDisipationBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerDisipation< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerDisipationBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + -hzInverse * ( + this->positiveDisipationFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_down , velocity_z_down , pressure_down , u[ down ] ) + - this->negativeDisipationFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_up , velocity_z_up , pressure_up , u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h new file mode 100644 index 000000000..3e372e54a --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h @@ -0,0 +1,592 @@ +/*************************************************************************** + VanLeerEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + VanLeerEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "VanLeerEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hzInverse * ( + this->positiveEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_z_down , velocity_x_down , velocity_y_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_z_up , velocity_x_up , velocity_y_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h new file mode 100644 index 000000000..d8e80c103 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h @@ -0,0 +1,145 @@ +/*************************************************************************** + VanLeerMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * ( - 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType dynamicalViscosity; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h new file mode 100644 index 000000000..04e41c015 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h @@ -0,0 +1,410 @@ +/*************************************************************************** + VanLeerMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h new file mode 100644 index 000000000..65ac84828 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h @@ -0,0 +1,381 @@ +/*************************************************************************** + VanLeerMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h new file mode 100644 index 000000000..125166cb8 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h @@ -0,0 +1,322 @@ +/*************************************************************************** + VanLeerMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h new file mode 100644 index 000000000..3a959ac91 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h @@ -0,0 +1,437 @@ +/*************************************************************************** + VanLeerTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "VanLeerTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + } + + RealType positiveTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return turbulentEnergy * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); + else + return turbulentEnergy * velocity; + }; + + RealType negativeTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return turbulentEnergy * velocity; + else if ( machNumber <= 1.0 ) + return - turbulentEnergy * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + -hzInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_down , velocity_z_down , pressure_down , u[ down ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_up , velocity_z_up , pressure_up , u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonContinuityOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonContinuityOperatorRightHandSide.h new file mode 100644 index 000000000..08663eb0c --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonContinuityOperatorRightHandSide.h @@ -0,0 +1,218 @@ +/*************************************************************************** + KEpsilonContinuityOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonContinuityRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + protected: + +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonContinuityRightHandSide +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonContinuityRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonContinuityRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonContinuityRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonContinuityRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonContinuityRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonContinuityRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + + return 0; + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h new file mode 100644 index 000000000..6c52ebcd2 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h @@ -0,0 +1,592 @@ +/*************************************************************************** + KEpsilonDisipationOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonDisipationRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + void setViscosityConstant1( const RealType& viscosityConstant1 ) + { + this->viscosityConstant1 = viscosityConstant1; + } + + void setViscosityConstant2( const RealType& viscosityConstant2 ) + { + this->viscosityConstant2 = viscosityConstant2; + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->sigmaEpsilon = sigmaEpsilon; + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->disipation = disipation; + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + MeshFunctionPointer turbulentEnergy; + + MeshFunctionPointer disipation; + + MeshFunctionPointer density; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; + + RealType viscosityConstant1; + + RealType viscosityConstant2; + + RealType sigmaEpsilon; +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonDisipationRightHandSide +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonDisipationRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonDisipationRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonDisipationRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& disipation_center = this->disipation.template getData< DeviceType >()[ center ]; + const RealType& disipation_west = this->disipation.template getData< DeviceType >()[ west ]; + const RealType& disipation_east = this->disipation.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_west + - disipation_center * turbulentViscosity_center + disipation_west * turbulentViscosity_west + ) * hxSquareInverse / this->sigmaEpsilon + + - this->viscosityConstant1 * disipation_center / turbulentEnergy_center + * 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + * turbulentViscosity_center + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + - this->viscosityConstant2 * density_center * disipation_center * disipation_center / turbulentEnergy_center; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonDisipationRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonDisipationRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonDisipationRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& disipation_center = this->disipation.template getData< DeviceType >()[ center ]; + const RealType& disipation_west = this->disipation.template getData< DeviceType >()[ west ]; + const RealType& disipation_east = this->disipation.template getData< DeviceType >()[ east ]; + const RealType& disipation_north = this->disipation.template getData< DeviceType >()[ north ]; + const RealType& disipation_south = this->disipation.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_west + - disipation_center * turbulentViscosity_center + disipation_west * turbulentViscosity_west + ) * hxSquareInverse / this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_north - 2 * disipation_center + disipation_south ) + * hySquareInverse + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_south + - disipation_center * turbulentViscosity_center + disipation_south * turbulentViscosity_south + ) * hySquareInverse / this->sigmaEpsioln + + - this->viscosityConstant1 * disipation_center / turbulentEnergy_center + * ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + ) * turbulentViscosity_center + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + + ( ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ) * turbulentViscosity_center + * ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + ) + + - this->viscosityConstant2 * density_center * disipation_center * disipation_center / turbulentEnergy_center; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonDisipationRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonDisipationRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonDisipationRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + const RealType& turbulentEnergy_up = this->turbulentEnergy.template getData< DeviceType >()[ up ]; + const RealType& turbulentEnergy_down = this->turbulentEnergy.template getData< DeviceType >()[ down ]; + + const RealType& disipation_center = this->disipation.template getData< DeviceType >()[ center ]; + const RealType& disipation_west = this->disipation.template getData< DeviceType >()[ west ]; + const RealType& disipation_east = this->disipation.template getData< DeviceType >()[ east ]; + const RealType& disipation_north = this->disipation.template getData< DeviceType >()[ north ]; + const RealType& disipation_south = this->disipation.template getData< DeviceType >()[ south ]; + const RealType& disipation_up = this->disipation.template getData< DeviceType >()[ up ]; + const RealType& disipation_down = this->disipation.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_west + - disipation_center * turbulentViscosity_center + disipation_west * turbulentViscosity_west + ) * hxSquareInverse / this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_north - 2 * disipation_center + disipation_south ) + * hySquareInverse + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_south + - disipation_center * turbulentViscosity_center + disipation_south * turbulentViscosity_south + ) * hySquareInverse / this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_up - 2 * disipation_center + disipation_down ) + * hySquareInverse + + ( disipation_up * turbulentViscosity_up - disipation_center * turbulentViscosity_down + - disipation_center * turbulentViscosity_center + disipation_down * turbulentViscosity_down + ) * hySquareInverse / this->sigmaEpsilon + + - this->viscosityConstant1 * disipation_center / turbulentEnergy_center + * ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_x_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) * turbulentViscosity_center + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + + ( ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + + + ( ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ) * turbulentViscosity_center + * ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) * turbulentViscosity_center + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + + + ( ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + + ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + ) * turbulentViscosity_center + * ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + + + ( ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + + ( ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + + ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + ) * turbulentViscosity_center + * ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + + + ( 4.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) + + - this->viscosityConstant2 * density_center * disipation_center * disipation_center / turbulentEnergy_center; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonEnergyOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonEnergyOperatorRightHandSide.h new file mode 100644 index 000000000..4f203a381 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonEnergyOperatorRightHandSide.h @@ -0,0 +1,687 @@ +/*************************************************************************** + KEpsilonEnergyOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonEnergyRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + KEpsilonEnergyRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + MeshFunctionPointer turbulentEnergy; + + MeshFunctionPointer density; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonEnergyRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonEnergyRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return +// 1D uT_11_x + 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity +// 1D_t_11_x + + + 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse + + + 2.0 / 3.0 * ( velocity_x_east * density_east * turbulentEnergy_east + - velocity_x_west * density_west * turbulentEnergy_west + ) * hxInverse / 2; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonEnergyRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return +// 2D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// vT_12_x + + ( ( velocity_x_northEast * velocity_y_east - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_west + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center - velocity_y_center * velocity_y_west + - velocity_y_center * velocity_y_center + velocity_y_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_21_y + + ( ( velocity_y_northEast * velocity_x_north - velocity_y_southEast * velocity_x_south + - velocity_y_northWest * velocity_x_north + velocity_y_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center - velocity_x_center * velocity_x_south + - velocity_x_center * velocity_x_center + velocity_x_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 2D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// ut_11_x + + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east * turbulentViscosity_east - velocity_y_southEast * velocity_x_east * turbulentViscosity_east + - velocity_y_northWest * velocity_x_west * turbulentViscosity_west + velocity_y_southWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( velocity_x_east * density_east * turbulentEnergy_east + - velocity_x_west * density_west * turbulentEnergy_west + ) * hxInverse / 2 + ) +// vt_12_x + + ( ( velocity_x_northEast * velocity_y_east * turbulentViscosity_east - velocity_x_southEast * velocity_y_east * turbulentViscosity_east + - velocity_x_northWest * velocity_y_west * turbulentViscosity_west + velocity_x_southWest * velocity_y_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_west * turbulentViscosity_west + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_west * velocity_y_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// ut_21_y + + ( ( velocity_y_northEast * velocity_x_north * turbulentViscosity_north - velocity_y_southEast * velocity_x_south * turbulentViscosity_south + - velocity_y_northWest * velocity_x_north * turbulentViscosity_north + velocity_y_southWest * velocity_x_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_south * turbulentViscosity_south + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_south * velocity_x_south * turbulentViscosity_south + ) * hySquareInverse + ) +// vt_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_south * turbulentViscosity_south + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_south * velocity_y_south * turbulentViscosity_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north * turbulentViscosity_north - velocity_x_southEast * velocity_y_south * turbulentViscosity_south + - velocity_x_northWest * velocity_y_north * turbulentViscosity_north + velocity_x_southWest * velocity_y_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( velocity_y_north * density_north * turbulentEnergy_north + - velocity_y_south * density_south * turbulentEnergy_south + ) * hyInverse / 2 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonEnergyRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + const RealType& turbulentEnergy_up = this->turbulentEnergy.template getData< DeviceType >()[ up ]; + const RealType& turbulentEnergy_down = this->turbulentEnergy.template getData< DeviceType >()[ down ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east + - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// vT_12_x + + ( ( velocity_x_northEast * velocity_y_east - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_west + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center - velocity_y_center * velocity_y_west + - velocity_y_center * velocity_y_center + velocity_y_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// wT_13_x + + ( ( velocity_x_upEast * velocity_z_east - velocity_x_downEast * velocity_z_east + - velocity_x_upWest * velocity_z_west + velocity_x_downWest * velocity_z_west + ) * hxInverse * hzInverse / 4 + + ( velocity_z_east * velocity_z_center - velocity_z_center * velocity_z_west + - velocity_z_center * velocity_z_center + velocity_z_west * velocity_z_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_21_y + + ( ( velocity_y_northEast * velocity_x_north - velocity_y_southEast * velocity_x_south + - velocity_y_northWest * velocity_x_north + velocity_y_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center - velocity_x_center * velocity_x_south + + velocity_x_center * velocity_x_center + velocity_x_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// wT_23_y + + ( ( velocity_y_upNorth * velocity_z_north - velocity_y_downNorth * velocity_y_north + - velocity_y_upSouth * velocity_z_south + velocity_y_downSouth * velocity_z_south + ) * hyInverse * hzInverse / 4 + + ( velocity_z_north * velocity_z_center - velocity_z_center * velocity_z_south + - velocity_z_center * velocity_z_center + velocity_z_south * velocity_z_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// uT_31_z + + ( ( velocity_x_up * velocity_x_center - velocity_x_center * velocity_x_center + - velocity_x_center * velocity_x_down + velocity_x_down * velocity_x_down + ) * hzSquareInverse + + ( velocity_z_upEast * velocity_x_up - velocity_z_downEast * velocity_x_down + - velocity_z_upWest * velocity_x_up + velocity_z_downWest * velocity_x_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_z + + ( ( velocity_z_upNorth * velocity_y_up - velocity_z_downNorth * velocity_y_down + - velocity_z_upSouth * velocity_y_up + velocity_z_downSouth * velocity_y_down + ) * hyInverse * hzInverse / 4 + + ( velocity_x_up * velocity_y_center - velocity_x_center * velocity_y_down + - velocity_x_center * velocity_y_center + velocity_x_down * velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down + - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down + - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down + - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// ut_11_x + + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east * turbulentViscosity_east - velocity_y_southEast * velocity_x_east * turbulentViscosity_east + - velocity_y_northWest * velocity_x_west * turbulentViscosity_west + velocity_y_southWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east * turbulentViscosity_east - velocity_z_downEast * velocity_x_east * turbulentViscosity_east + - velocity_z_upWest * velocity_x_west * turbulentViscosity_west + velocity_z_downWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( velocity_y_north * density_north * turbulentEnergy_north + - velocity_y_south * density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// vt_12_x + + ( ( velocity_x_northEast * velocity_y_east * turbulentViscosity_east - velocity_x_southEast * velocity_y_east * turbulentViscosity_east + - velocity_x_northWest * velocity_y_west * turbulentViscosity_west + velocity_x_southWest * velocity_y_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_west * turbulentViscosity_west + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_west * velocity_y_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// wt_13_x + + ( ( velocity_x_upEast * velocity_z_east * turbulentViscosity_east - velocity_x_downEast * velocity_z_east * turbulentViscosity_east + - velocity_x_upWest * velocity_z_west * turbulentViscosity_west + velocity_x_downWest * velocity_z_west * turbulentViscosity_west + ) * hxInverse * hzInverse / 4 + + ( velocity_z_east * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_west * turbulentViscosity_west + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_west * velocity_z_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// ut_21_y + + ( ( velocity_y_northEast * velocity_x_north * turbulentViscosity_north - velocity_y_southEast * velocity_x_south * turbulentViscosity_south + - velocity_y_northWest * velocity_x_north * turbulentViscosity_north + velocity_y_southWest * velocity_x_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_south * turbulentViscosity_south + + velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_south * velocity_x_south * turbulentViscosity_south + ) * hySquareInverse + ) +// vt_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_south * turbulentViscosity_south + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_south * velocity_y_south * turbulentViscosity_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north * turbulentViscosity_north - velocity_x_southEast * velocity_y_south * turbulentViscosity_south + - velocity_x_northWest * velocity_y_north * turbulentViscosity_north + velocity_x_southWest * velocity_y_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north * turbulentViscosity_north - velocity_z_downNorth * velocity_y_north * turbulentViscosity_north + - velocity_z_upSouth * velocity_y_south * turbulentViscosity_south + velocity_z_downSouth * velocity_y_south * turbulentViscosity_south + ) * hyInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( velocity_y_north * density_north * turbulentEnergy_north + - velocity_y_south * density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// wt_23_y + + ( ( velocity_y_upNorth * velocity_z_north * turbulentViscosity_north - velocity_y_downNorth * velocity_y_north * turbulentViscosity_north + - velocity_y_upSouth * velocity_z_south * turbulentViscosity_south + velocity_y_downSouth * velocity_z_south * turbulentViscosity_south + ) * hyInverse * hzInverse / 4 + + ( velocity_z_north * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_south * turbulentViscosity_south + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_south * velocity_z_south * turbulentViscosity_south + ) * hySquareInverse + ) +// ut_31_z + + ( ( velocity_x_up * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_center * turbulentViscosity_center + - velocity_x_center * velocity_x_down * turbulentViscosity_down + velocity_x_down * velocity_x_down * turbulentViscosity_down + ) * hzSquareInverse + + ( velocity_z_upEast * velocity_x_up * turbulentViscosity_up - velocity_z_downEast * velocity_x_down * turbulentViscosity_down + - velocity_z_upWest * velocity_x_up * turbulentViscosity_up + velocity_z_downWest * velocity_x_down * turbulentViscosity_down + ) * hxInverse * hzInverse / 4 + ) +// vt_32_z + + ( ( velocity_z_upNorth * velocity_y_up * turbulentViscosity_up - velocity_z_downNorth * velocity_y_down * turbulentViscosity_down + - velocity_z_upSouth * velocity_y_up * turbulentViscosity_up + velocity_z_downSouth * velocity_y_down * turbulentViscosity_down + ) * hyInverse * hzInverse / 4 + + ( velocity_x_up * velocity_y_center * turbulentViscosity_center - velocity_x_center * velocity_y_down * turbulentViscosity_down + - velocity_x_center * velocity_y_center * turbulentViscosity_center + velocity_x_down * velocity_y_down * turbulentViscosity_down + ) * hzSquareInverse + ) +// wt_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_down * turbulentViscosity_down + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_down * velocity_z_down * turbulentViscosity_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up * turbulentViscosity_up - velocity_y_downNorth * velocity_z_down * turbulentViscosity_down + - velocity_y_upSouth * velocity_z_up * turbulentViscosity_up + velocity_y_downSouth * velocity_z_down * turbulentViscosity_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up * turbulentViscosity_up - velocity_x_downEast * velocity_z_down * turbulentViscosity_down + - velocity_x_upWest * velocity_z_up * turbulentViscosity_up + velocity_x_downWest * velocity_z_down * turbulentViscosity_down + ) * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( velocity_z_up * density_up * turbulentEnergy_up + - velocity_z_down * density_down * turbulentEnergy_down + ) * hzInverse / 2 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumBaseOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumBaseOperatorRightHandSide.h new file mode 100644 index 000000000..36ce9b3df --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumBaseOperatorRightHandSide.h @@ -0,0 +1,75 @@ +/*************************************************************************** + KEpsilonMomentumRightHandSideBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonMomentumRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + KEpsilonMomentumRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + MeshFunctionPointer turbulentEnergy; + + MeshFunctionPointer density; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumXOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumXOperatorRightHandSide.h new file mode 100644 index 000000000..a213cdc72 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumXOperatorRightHandSide.h @@ -0,0 +1,450 @@ +/*************************************************************************** + KEpsilonMomentumXRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "KEpsilonMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonMomentumXRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonMomentumXRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return +// 1D T_11_x + 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity +// 1D t_11_x + + + 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse + + + 2.0 / 3.0 * ( density_east * turbulentEnergy_east + - density_west * turbulentEnergy_west + ) * hxInverse / 2; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return +// 2D T_11_x + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// t_11_x + + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( density_east * turbulentEnergy_east + - density_west * turbulentEnergy_west + ) * hxInverse / 2 + ) +// t_21_y + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + ) * hySquareInverse + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D T_11_x + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hxSquareInverse + ) * this->dynamicalViscosity +// T_31_z + + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + + ( velocity_x_up - 2 * velocity_x_center + velocity_x_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +//t_11_x + + + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest + velocity_z_downWest ) + ) * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( density_east * turbulentEnergy_east + - density_west * turbulentEnergy_west + ) * hxInverse / 2 + ) +// t_21_y + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north - turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + ) * hySquareInverse + ) +// t_31_z + + ( ( turbulentViscosity_up * ( velocity_z_upEast - velocity_z_upWest ) - turbulentViscosity_down * ( velocity_z_downEast - velocity_z_downWest ) + ) * hxInverse * hzInverse / 4 + + ( turbulentViscosity_up * velocity_x_up - ( turbulentViscosity_up + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_down + ) * hzSquareInverse + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumYOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumYOperatorRightHandSide.h new file mode 100644 index 000000000..a5597847a --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumYOperatorRightHandSide.h @@ -0,0 +1,417 @@ +/*************************************************************************** + KEpsilonMomentumYRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "KEpsilonMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonMomentumYRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonMomentumYRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonMomentumYRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + + return +// 2D T_22_y + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_12_x + + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east + ) * hxSquareInverse + ) * this->dynamicalViscosity + + +// t_22_y + ( 4.0 / 3.0 * ( turbulentViscosity_north * velocity_y_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_x_northEast - velocity_x_northWest ) - turbulentViscosity_south * ( velocity_x_southEast - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( density_north * turbulentEnergy_north + - density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// t_12_x + + ( ( turbulentViscosity_east * (velocity_x_northEast - velocity_x_southEast ) - turbulentViscosity_west * (velocity_x_northWest - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_east * velocity_y_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_west + ) * hxSquareInverse + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonMomentumYRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// T_12_y + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east - 2 * velocity_y_center + velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// 3D T_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_y + + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + + ( velocity_y_up - 2 * velocity_y_center + velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity + + +// t_12_x + ( ( turbulentViscosity_east * ( velocity_x_northEast - velocity_x_southEast ) - turbulentViscosity_west * ( velocity_x_northWest - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_east * velocity_y_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_west + ) * hxSquareInverse + ) +// t_22_y + + ( 4.0 / 3.0 * ( turbulentViscosity_north * velocity_y_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_x_northEast - velocity_x_northWest ) - turbulentViscosity_south * ( velocity_x_southEast - velocity_x_southWest) + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_z_upNorth - velocity_z_downNorth ) - turbulentViscosity_south * ( velocity_z_upSouth - velocity_z_downSouth ) + ) * hyInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( density_north * turbulentEnergy_north + - density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// t_32_z + + ( ( turbulentViscosity_up * ( velocity_z_upNorth - velocity_z_upSouth ) - turbulentViscosity_down * ( velocity_z_downNorth - velocity_z_downSouth ) + ) * hyInverse * hzInverse / 4 + + ( turbulentViscosity_up * velocity_y_up - ( turbulentViscosity_up + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_down + ) * hzSquareInverse + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumZOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumZOperatorRightHandSide.h new file mode 100644 index 000000000..0ff824ae1 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumZOperatorRightHandSide.h @@ -0,0 +1,343 @@ +/*************************************************************************** + KEpsilonMomentumZRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "KEpsilonMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonMomentumZRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonMomentumZRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonMomentumZRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_up = this->turbulentEnergy.template getData< DeviceType >()[ up ]; + const RealType& turbulentEnergy_down = this->turbulentEnergy.template getData< DeviceType >()[ down ]; + + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// T_13_x + ( ( velocity_z_east - 2 * velocity_z_center + velocity_z_west ) + * hxSquareInverse + + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// T_23_y + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + * hySquareInverse + ) + * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// t_13_x + + ( ( turbulentViscosity_east * velocity_z_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_west ) + * hxSquareInverse + + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest + velocity_x_downWest ) ) + * hxInverse * hzInverse / 4 + ) +// t_23_y + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + * hySquareInverse + ) +// t_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( density_up * turbulentEnergy_up + - density_down * turbulentEnergy_down + ) * hzInverse / 2 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h new file mode 100644 index 000000000..2c4277960 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h @@ -0,0 +1,169 @@ +/*************************************************************************** + KEpsilonOpratorRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "KEpsilonContinuityOperatorRightHandSide.h" +#include "KEpsilonEnergyOperatorRightHandSide.h" +#include "KEpsilonMomentumXOperatorRightHandSide.h" +#include "KEpsilonMomentumYOperatorRightHandSide.h" +#include "KEpsilonMomentumZOperatorRightHandSide.h" +#include "KEpsilonTurbulentEnergyOperatorRightHandSide.h" +#include "KEpsilonDisipationOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonOperatorRightHandSide +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef KEpsilonContinuityRightHandSide< Mesh, Real, Index > ContinuityOperatorRightHandSideType; + typedef KEpsilonMomentumXRightHandSide< Mesh, Real, Index > MomentumXOperatorRightHandSideType; + typedef KEpsilonMomentumYRightHandSide< Mesh, Real, Index > MomentumYOperatorRightHandSideType; + typedef KEpsilonMomentumZRightHandSide< Mesh, Real, Index > MomentumZOperatorRightHandSideType; + typedef KEpsilonEnergyRightHandSide< Mesh, Real, Index > EnergyOperatorRightHandSideType; + typedef KEpsilonTurbulentEnergyRightHandSide< Mesh, Real, Index > TurbulentEnergyOperatorRightHandSideType; + typedef KEpsilonDisipationRightHandSide< Mesh, Real, Index > DisipationOperatorRightHandSideType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorRightHandSideType > ContinuityOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumXOperatorRightHandSideType > MomentumXOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumYOperatorRightHandSideType > MomentumYOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumZOperatorRightHandSideType > MomentumZOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< EnergyOperatorRightHandSideType > EnergyOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorRightHandSideType > TurbulentEnergyOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< DisipationOperatorRightHandSideType > DisipationOperatorRightHandSidePointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + KEpsilonOperatorRightHandSide() + : dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + return true; + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumXOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumYOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumZOperatorRightHandSidePointer->setVelocity( velocity ); + this->energyOperatorRightHandSidePointer->setVelocity( velocity ); + this->turbulentEnergyOperatorRightHandSidePointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->momentumXOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->turbulentEnergyOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorRightHandSidePointer->setDensity( density ); + this->momentumYOperatorRightHandSidePointer->setDensity( density ); + this->momentumZOperatorRightHandSidePointer->setDensity( density ); + this->energyOperatorRightHandSidePointer->setDensity( density ); + this->turbulentEnergyOperatorRightHandSidePointer->setDenity( density ); + } + + const ContinuityOperatorRightHandSidePointer& getContinuityOperatorRightHandSide() const + { + return this->continuityOperatorRightHandSidePointer; + } + + const MomentumXOperatorRightHandSidePointer& getMomentumXOperatorRightHandSide() const + { + return this->momentumXOperatorRightHandSidePointer; + } + + const MomentumYOperatorRightHandSidePointer& getMomentumYOperatorRightHandSide() const + { + return this->momentumYOperatorRightHandSidePointer; + } + + const MomentumZOperatorRightHandSidePointer& getMomentumZOperatorRightHandSide() const + { + return this->momentumZOperatorRightHandSidePointer; + } + + const EnergyOperatorRightHandSidePointer& getEnergyOperatorRightHandSide() const + { + return this->energyOperatorRightHandSidePointer; + } + + const TurbulentEnergyOperatorRightHandSidePointer& getTurbulentEnergyOperatorRightHandSide() const + { + return this->turbulentEnergyOperatorRightHandSidePointer; + } + + const DisipationOperatorRightHandSidePointer& getDisipationOperatorRightHandSide() const + { + return this->disipationOperatorRightHandSidePointer; + } + + protected: + + ContinuityOperatorRightHandSidePointer continuityOperatorPointer; + MomentumXOperatorRightHandSidePointer momentumXOperatorPointer; + MomentumYOperatorRightHandSidePointer momentumYOperatorPointer; + MomentumZOperatorRightHandSidePointer momentumZOperatorPointer; + EnergyOperatorRightHandSidePointer energyOperatorPointer; + TurbulentEnergyOperatorRightHandSidePointer turbulentEnergyOperatorPointer; + DisipationOperatorRightHandSidePointer disipationOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonTurbulentEnergyOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonTurbulentEnergyOperatorRightHandSide.h new file mode 100644 index 000000000..d08930d62 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonTurbulentEnergyOperatorRightHandSide.h @@ -0,0 +1,528 @@ +/*************************************************************************** + KEpsilonTurbulentEnergyOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonTurbulentEnergyRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + + + static String getType() + { + return String( "LaxFridrichsTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + void setSigmaK( const RealType& sigmaK ) + { + this->sigmaK = sigmaK; + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + MeshFunctionPointer turbulentEnergy; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; + + RealType sigmaK; +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KEpsilonTurbulentEnergyRightHandSide +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonTurbulentEnergyRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonTurbulentEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return + this->dynamicalViscosity + * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) + * hxSquareInverse + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + ) * hxSquareInverse / this->sigmaK + - + 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + * turbulentViscosity_center + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonTurbulentEnergyRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonTurbulentEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return + this->dynamicalViscosity + * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) + * hxSquareInverse + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + ) * hxSquareInverse / this->sigmaK + + + this->dynamicalViscosity + * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) + * hySquareInverse + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + ) * hySquareInverse / this->sigmaK + + - ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + ) * turbulentViscosity_center + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + + ( ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ) * turbulentViscosity_center + * ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public KEpsilonTurbulentEnergyRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KEpsilonTurbulentEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + const RealType& turbulentEnergy_up = this->turbulentEnergy.template getData< DeviceType >()[ up ]; + const RealType& turbulentEnergy_down = this->turbulentEnergy.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return + this->dynamicalViscosity + * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) + * hxSquareInverse + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + ) * hxSquareInverse / this->sigmaK + + + this->dynamicalViscosity + * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) + * hySquareInverse + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + ) * hySquareInverse / this->sigmaK + + + this->dynamicalViscosity + * ( turbulentEnergy_up - 2 * turbulentEnergy_center + turbulentEnergy_down ) + * hySquareInverse + + ( turbulentEnergy_up * turbulentViscosity_up - turbulentEnergy_center * turbulentViscosity_down + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_down * turbulentViscosity_down + ) * hySquareInverse / this->sigmaK + + - ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_x_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) * turbulentViscosity_center + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + + ( ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + + + ( ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ) * turbulentViscosity_center + * ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) * turbulentViscosity_center + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + + + ( ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + + ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + ) * turbulentViscosity_center + * ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + + + ( ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + + ( ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + + ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + ) * turbulentViscosity_center + * ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + + + ( 4.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ) * turbulentViscosity_center + * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/PhysicalVariablesGetter.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/PhysicalVariablesGetter.h new file mode 100644 index 000000000..452620d0d --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/PhysicalVariablesGetter.h @@ -0,0 +1,243 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { + +template< typename Mesh > +class PhysicalVariablesGetter +{ + public: + + typedef Mesh MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + VelocityGetter( MeshFunctionPointer density, + MeshFunctionPointer momentum ) + : density( density ), momentum( momentum ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return momentum.template getData< DeviceType >()( meshEntity ) / + density.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, momentum; + }; + + class PressureGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + PressureGetter( MeshFunctionPointer density, + MeshFunctionPointer energy, + VelocityFieldPointer momentum, + const RealType& gamma ) + : density( density ), energy( energy ), momentum( momentum ), gamma( gamma ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + const RealType e = energy.template getData< DeviceType >()( meshEntity ); + const RealType rho = density.template getData< DeviceType >()( meshEntity ); + const RealType momentumNorm = momentum.template getData< DeviceType >().getVector( meshEntity ).lpNorm( 2.0 ); + if( rho == 0.0 ) + return 0; + else + return ( gamma - 1.0 ) * ( e - 0.5 * momentumNorm * momentumNorm / rho ); + } + + protected: + const MeshFunctionPointer density, energy; + const VelocityFieldPointer momentum; + const RealType gamma; + }; + + class TurbulentEnergyGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + TurbulentEnergyGetter( MeshFunctionPointer density, + MeshFunctionPointer turbulentEnergyXDensity ) + : density( density ), turbulentEnergyXDensity( turbulentEnergyXDensity ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return turbulentEnergyXDensity.template getData< DeviceType >()( meshEntity ) / + density.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, turbulentEnergyXDensity; + }; + + class DisipationGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + DisipationGetter( MeshFunctionPointer density, + MeshFunctionPointer disipationXDensity ) + : density( density ), disipationXDensity( disipationXDensity ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return disipationXDensity.template getData< DeviceType >()( meshEntity ) / + density.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, disipationXDensity; + }; + + class TurbulentViscosityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + TurbulentViscosityGetter( MeshFunctionPointer density, + MeshFunctionPointer turbulentEnergy, + RealType turbulenceConstant, + MeshFunctionPointer disipation ) + : density( density ), turbulentEnergy( turbulentEnergy ), turbulenceConstant( turbulenceConstant ), disipation( disipation ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( disipation.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return density.template getData< DeviceType >()( meshEntity ) * turbulenceConstant + * turbulentEnergy.template getData< DeviceType >()( meshEntity ) + * turbulentEnergy.template getData< DeviceType >()( meshEntity ) + / disipation.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, turbulentEnergy, disipation; + const RealType turbulenceConstant; + }; + + + void getVelocity( const ConservativeVariablesPointer& conservativeVariables, + VelocityFieldPointer& velocity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), + ( *conservativeVariables->getMomentum() )[ i ] ); + evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); + } + } + + void getPressure( const ConservativeVariablesPointer& conservativeVariables, + const RealType& gamma, + MeshFunctionPointer& pressure ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; + Pointers::SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), + conservativeVariables->getEnergy(), + conservativeVariables->getMomentum(), + gamma ); + evaluator.evaluate( pressure, pressureGetter ); + } + + void getTurbulentEnergy( const ConservativeVariablesPointer& conservativeVariables, + MeshFunctionPointer& turbulentEnergy_no_rho ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, TurbulentEnergyGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< TurbulentEnergyGetter, DeviceType > turbulentEnergyGetter( conservativeVariables->getDensity(), + conservativeVariables->getTurbulentEnergy() ); + evaluator.evaluate( turbulentEnergy_no_rho, turbulentEnergyGetter ); + } + } + + void getDisipation( const ConservativeVariablesPointer& conservativeVariables, + MeshFunctionPointer& disipation_no_rho ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, DisipationGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< DisipationGetter, DeviceType > disipationGetter( conservativeVariables->getDensity(), + conservativeVariables->getDisipation() ); + evaluator.evaluate( disipation_no_rho, disipationGetter ); + } + } + + void getTurbulentViscosity( const ConservativeVariablesPointer& conservativeVariables, + MeshFunctionPointer& turbulentEnergy_no_rho, + MeshFunctionPointer& disipation_no_rho, + const RealType& turbulenceConstant, + MeshFunctionPointer& turbulentViscosity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, TurbulentViscosityGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< TurbulentViscosityGetter, DeviceType > turbulentViscosityGetter( conservativeVariables->getDensity(), + turbulentEnergy_no_rho, + turbulenceConstant, + disipation_no_rho); + evaluator.evaluate( turbulentViscosity, turbulentViscosityGetter ); + } + } + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/RiemannProblemInitialCondition.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/RiemannProblemInitialCondition.h new file mode 100644 index 000000000..90a456fb4 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/RiemannProblemInitialCondition.h @@ -0,0 +1,1896 @@ +/*************************************************************************** + RiemannProblemInitialCondition.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { +template +class RiemannProblemInitialConditionSetter +{ + +}; + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 1,MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setTurbulentEnergy(RealType NWUTurbulentEnergy, + RealType NEUTurbulentEnergy, + RealType SWUTurbulentEnergy, + RealType SEUTurbulentEnergy, + RealType NWDTurbulentEnergy, + RealType NEDTurbulentEnergy, + RealType SWDTurbulentEnergy, + RealType SEDTurbulentEnergy) + { + this->NWUTurbulentEnergy = NWUTurbulentEnergy; + this->NEUTurbulentEnergy = NEUTurbulentEnergy; + this->SWUTurbulentEnergy = SWUTurbulentEnergy; + this->SEUTurbulentEnergy = SEUTurbulentEnergy; + this->NWDTurbulentEnergy = NWDTurbulentEnergy; + this->NEDTurbulentEnergy = NEDTurbulentEnergy; + this->SWDTurbulentEnergy = SWDTurbulentEnergy; + this->SEDTurbulentEnergy = SEDTurbulentEnergy; + }; + + void setDisipation(RealType NWUDisipation, + RealType NEUDisipation, + RealType SWUDisipation, + RealType SEUDisipation, + RealType NWDDisipation, + RealType NEDDisipation, + RealType SWDDisipation, + RealType SEDDisipation) + { + this->NWUDisipation = NWUDisipation; + this->NEUDisipation = NEUDisipation; + this->SWUDisipation = SWUDisipation; + this->SEUDisipation = SEUDisipation; + this->NWDDisipation = NWDDisipation; + this->NEDDisipation = NEDDisipation; + this->SWDDisipation = SWDDisipation; + this->SEDDisipation = SEDDisipation; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + }; + + + void placeTurbulentEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWDTurbulentEnergy); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEDTurbulentEnergy); + } + }; + + void placeDisipation(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SWDDisipation); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SEDDisipation); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + RealType NWUDisipation, NEUDisipation, SWUDisipation, SEUDisipation, NWDDisipation, NEDDisipation, SWDDisipation, SEDDisipation; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 2,MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setTurbulentEnergy(RealType NWUTurbulentEnergy, + RealType NEUTurbulentEnergy, + RealType SWUTurbulentEnergy, + RealType SEUTurbulentEnergy, + RealType NWDTurbulentEnergy, + RealType NEDTurbulentEnergy, + RealType SWDTurbulentEnergy, + RealType SEDTurbulentEnergy) + { + this->NWUTurbulentEnergy = NWUTurbulentEnergy; + this->NEUTurbulentEnergy = NEUTurbulentEnergy; + this->SWUTurbulentEnergy = SWUTurbulentEnergy; + this->SEUTurbulentEnergy = SEUTurbulentEnergy; + this->NWDTurbulentEnergy = NWDTurbulentEnergy; + this->NEDTurbulentEnergy = NEDTurbulentEnergy; + this->SWDTurbulentEnergy = SWDTurbulentEnergy; + this->SEDTurbulentEnergy = SEDTurbulentEnergy; + }; + + void setDisipation(RealType NWUDisipation, + RealType NEUDisipation, + RealType SWUDisipation, + RealType SEUDisipation, + RealType NWDDisipation, + RealType NEDDisipation, + RealType SWDDisipation, + RealType SEDDisipation) + { + this->NWUDisipation = NWUDisipation; + this->NEUDisipation = NEUDisipation; + this->SWUDisipation = SWUDisipation; + this->SEUDisipation = SEUDisipation; + this->NWDDisipation = NWDDisipation; + this->NEDDisipation = NEDDisipation; + this->SWDDisipation = SWDDisipation; + this->SEDDisipation = SEDDisipation; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); + } + }; + + void placeTurbulentEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEDTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NEDTurbulentEnergy); + } + }; + + void placeDisipation(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SWDDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SEDDisipation); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->NWDDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->NEDDisipation); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + RealType NWUDisipation, NEUDisipation, SWUDisipation, SEUDisipation, NWDDisipation, NEDDisipation, SWDDisipation, SEDDisipation; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setTurbulentEnergy(RealType NWUTurbulentEnergy, + RealType NEUTurbulentEnergy, + RealType SWUTurbulentEnergy, + RealType SEUTurbulentEnergy, + RealType NWDTurbulentEnergy, + RealType NEDTurbulentEnergy, + RealType SWDTurbulentEnergy, + RealType SEDTurbulentEnergy) + { + this->NWUTurbulentEnergy = NWUTurbulentEnergy; + this->NEUTurbulentEnergy = NEUTurbulentEnergy; + this->SWUTurbulentEnergy = SWUTurbulentEnergy; + this->SEUTurbulentEnergy = SEUTurbulentEnergy; + this->NWDTurbulentEnergy = NWDTurbulentEnergy; + this->NEDTurbulentEnergy = NEDTurbulentEnergy; + this->SWDTurbulentEnergy = SWDTurbulentEnergy; + this->SEDTurbulentEnergy = SEDTurbulentEnergy; + }; + + void setDisipation(RealType NWUDisipation, + RealType NEUDisipation, + RealType SWUDisipation, + RealType SEUDisipation, + RealType NWDDisipation, + RealType NEDDisipation, + RealType SWDDisipation, + RealType SEDDisipation) + { + this->NWUDisipation = NWUDisipation; + this->NEUDisipation = NEUDisipation; + this->SWUDisipation = SWUDisipation; + this->SEUDisipation = SEUDisipation; + this->NWDDisipation = NWDDisipation; + this->NEDDisipation = NEDDisipation; + this->SWDDisipation = SWDDisipation; + this->SEDDisipation = SEDDisipation; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWDMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEDMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NWDMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NEDMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); + } + }; + + void placeTurbulentEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEDTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NEDTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWUTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEUTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWUTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEUTurbulentEnergy); + } + }; + + void placeDisipation(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SWDDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SEDDisipation); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->NWDDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->NEDDisipation); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SWUDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SEUDisipation); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SWUDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SEUDisipation); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + RealType NWUDisipation, NEUDisipation, SWUDisipation, SEUDisipation, NWDDisipation, NEDDisipation, SWDDisipation, SEDDisipation; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + +template< typename Mesh > +class RiemannProblemInitialCondition +{ + public: + + typedef Mesh MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; + + RiemannProblemInitialCondition() + : discontinuityPlacement( 0.5 ), + leftDensity( 1.0 ), rightDensity( 1.0 ), + leftVelocity( -2.0 ), rightVelocity( 2.0 ), + leftPressure( 0.4 ), rightPressure( 0.4 ), + gamma( 1.67 ){} + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "discontinuity-placement-0", "x-coordinate of the discontinuity placement.", 0.5 ); + config.addEntry< double >( prefix + "discontinuity-placement-1", "y-coordinate of the discontinuity placement.", 0.5 ); + config.addEntry< double >( prefix + "discontinuity-placement-2", "z-coordinate of the discontinuity placement.", 0.5 ); +/* + config.addEntry< double >( prefix + "left-density", "Density on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-density", "Density on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "left-velocity-0", "x-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "left-velocity-1", "y-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "left-velocity-2", "z-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-velocity-0", "x-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "right-velocity-1", "y-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "right-velocity-2", "z-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "left-pressure", "Pressure on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-pressure", "Pressure on the right side of the discontinuity.", 0.0 ); +*/ + config.addEntry< double >( prefix + "NWU-density", "This sets a value of northwest up density.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-0", "This sets a value of northwest up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-1", "This sets a value of northwest up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-2", "This sets a value of northwest up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-pressure", "This sets a value of northwest up pressure.", 1.0 ); + config.addEntry< double >( prefix + "SWU-density", "This sets a value of southwest up density.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-0", "This sets a value of southwest up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-1", "This sets a value of southwest up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-2", "This sets a value of southwest up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-pressure", "This sets a value of southwest up pressure.", 1.0 ); + config.addEntry< double >( prefix + "NWD-density", "This sets a value of northwest down density.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-0", "This sets a value of northwest down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-1", "This sets a value of northwest down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-2", "This sets a value of northwest down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-pressure", "This sets a value of northwest down pressure.", 1.0 ); + config.addEntry< double >( prefix + "SWD-density", "This sets a value of southwest down density.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-0", "This sets a value of southwest down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-1", "This sets a value of southwest down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-2", "This sets a value of southwest down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-pressure", "This sets a value of southwest down pressure.", 1.0 ); + config.addEntry< double >( prefix + "NEU-density", "This sets a value of northeast up density.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-0", "This sets a value of northeast up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-1", "This sets a value of northeast up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-2", "This sets a value of northeast up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-pressure", "This sets a value of northeast up pressure.", 1.0 ); + config.addEntry< double >( prefix + "SEU-density", "This sets a value of southeast up density.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-0", "This sets a value of southeast up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-1", "This sets a value of southeast up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-2", "This sets a value of southeast up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-pressure", "This sets a value of southeast up pressure.", 1.0 ); + config.addEntry< double >( prefix + "NED-density", "This sets a value of northeast down density.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-0", "This sets a value of northeast down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-1", "This sets a value of northeast down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-2", "This sets a value of northeast down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-pressure", "This sets a value of northeast down pressure.", 1.0 ); + config.addEntry< double >( prefix + "SED-density", "This sets a value of southeast down density.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-0", "This sets a value of southeast down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-1", "This sets a value of southeast down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-2", "This sets a value of southeast down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-pressure", "This sets a value of southeast down pressure.", 1.0 ); + config.addEntry< double >( prefix + "gamma", "Gamma in the ideal gas state equation.", 1.4 ); + + config.addEntry< String >( prefix + "initial", " One of predefined initial condition.", "none"); + config.addEntryEnum< String >( "none" ); + config.addEntryEnum< String >( "1D_2" ); + config.addEntryEnum< String >( "1D_3a" ); + config.addEntryEnum< String >( "1D_4" ); + config.addEntryEnum< String >( "1D_5" ); + config.addEntryEnum< String >( "1D_6" ); + config.addEntryEnum< String >( "1D_Noh" ); + config.addEntryEnum< String >( "1D_peak" ); + config.addEntryEnum< String >( "2D_3" ); + config.addEntryEnum< String >( "2D_4" ); + config.addEntryEnum< String >( "2D_6" ); + config.addEntryEnum< String >( "2D_12" ); + config.addEntryEnum< String >( "2D_15" ); + config.addEntryEnum< String >( "2D_17" ); + } + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + String initial = parameters.getParameter< String >( prefix + "initial" ); + if(initial == prefix + "none") + { + this->intensity = parameters.getParameter< double >( "turbulence-intensity" ); + this->turbulenceConstant = parameters.getParameter< double >( "turbulence-constant" ); + this->lengthScale = parameters.getParameter< double >( "turbulence-length-scale" ); + this->discontinuityPlacement.setup( parameters, prefix + "discontinuity-placement-" ); + this->gamma = parameters.getParameter< double >( prefix + "gamma" ); +/* + this->leftVelocity.setup( parameters, prefix + "left-velocity-" ); + this->rightVelocity.setup( parameters, prefix + "right-velocity-" ); + this->leftDensity = parameters.getParameter< double >( prefix + "left-density" ); + this->rightDensity = parameters.getParameter< double >( prefix + "right-density" ); + this->leftPressure = parameters.getParameter< double >( prefix + "left-pressure" ); + this->rightPressure = parameters.getParameter< double >( prefix + "right-pressure" ); +*/ + + this->NWUDensity = parameters.getParameter< RealType >( prefix + "NWU-density" ); + this->NWUVelocity.setup( parameters, prefix + "NWU-velocity-" ); + this->NWUPressure = parameters.getParameter< RealType >( prefix + "NWU-pressure" ); + this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); + this->NWUMomentum = NWUVelocity * NWUDensity; + this->NWUTurbulentEnergy = this->NWUDensity * TurbulentEnergy( NWUVelocity, this->intensity); + this->NWUDisipation = this->turbulenceConstant * std::pow( NWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); + this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); + this->SWUPressure = parameters.getParameter< RealType >( prefix + "SWU-pressure" ); + this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); + this->SWUMomentum = SWUVelocity * SWUDensity; + this->SWUTurbulentEnergy = SWUDensity * TurbulentEnergy( SWUVelocity, this->intensity); + this->SWUDisipation = this->turbulenceConstant * std::pow( SWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); + this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); + this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); + this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); + this->NWDMomentum = NWDVelocity * NWDDensity; + this->NWDTurbulentEnergy = NWDDensity * TurbulentEnergy( NWDVelocity, this->intensity); + this->NWDDisipation = this->turbulenceConstant * std::pow( NWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); + this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); + this->SWDPressure = parameters.getParameter< RealType >( prefix + "SWD-pressure" ); + this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); + this->SWDMomentum = SWDVelocity * SWDDensity; + this->SWDTurbulentEnergy = SWDDensity * TurbulentEnergy( SWDVelocity, this->intensity); + this->SWDDisipation = this->turbulenceConstant * std::pow( SWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); + this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); + this->NEUPressure = parameters.getParameter< RealType >( prefix + "NEU-pressure" ); + this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); + this->NEUMomentum = NEUVelocity * NEUDensity; + this->NEUTurbulentEnergy = NEUDensity * TurbulentEnergy( NEUVelocity, this->intensity); + this->NEUDisipation = this->turbulenceConstant * std::pow( NEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); + this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); + this->SEUPressure = parameters.getParameter< RealType >( prefix + "SEU-pressure" ); + this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); + this->SEUMomentum = SEUVelocity * SEUDensity; + this->SEUTurbulentEnergy = SEUDensity * TurbulentEnergy( SEUVelocity, this->intensity); + this->SEUDisipation = this->turbulenceConstant * std::pow( SEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); + this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); + this->NEDPressure = parameters.getParameter< RealType >( prefix + "NED-pressure" ); + this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); + this->NEDMomentum = NEDVelocity * NEDDensity; + this->NEDTurbulentEnergy = NEDDensity * TurbulentEnergy( NEDVelocity, this->intensity); + this->NEDDisipation = this->turbulenceConstant * std::pow( NEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); + this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); + this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); + this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); + this->SEDMomentum = SEDVelocity * SEDDensity; + this->SEDTurbulentEnergy = SEDDensity * TurbulentEnergy( SEDVelocity, this->intensity); + this->SEDDisipation = this->turbulenceConstant * std::pow( SEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + } + if(initial == prefix + "1D_2") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -2.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 2.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_3a") + predefinedInitialCondition( 1.4, 0.8, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 1000.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.01, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -19.59745, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -19.59745, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_4") + predefinedInitialCondition( 1.666, 0.4, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 5.99924, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 5.99242, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 460.894, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 46.095, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 19.5975, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -6.19633, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_5") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_6") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.1, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_Noh") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.000001, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.000001, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_peak") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 0.12612, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 6.5915, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 782.929, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 3.15449, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 8.90470, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 2.26542, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_3") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5323, 0.138, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.5, 0.5323, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.3, 0.029, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.5, 0.3, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 1.206, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.206, 1.206, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 1.206, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_4") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5065, 1.1, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.1, 0.5065, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.35, 1.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.1, 0.35, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.8939, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.8939, 0.8939, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.8939, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + + if(initial == prefix + "2D_6") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 2.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 3.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.75, 0.5, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -0.75, 0.5, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.75, -0.5, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -0.75, -0.5, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_12") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 1.0, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.5313, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.4, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.7276, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.7276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + + if(initial == prefix + "2D_15") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5197, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 0.5313, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.4, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + -0.6259, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.1, -0.3, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.1, -0.3, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.1, 0.4276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_17") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 2.0, 1.0625, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 0.5197, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.2145, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, -0.4, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 1.1259, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + return true; + } + + void setDiscontinuityPlacement( const PointType& v ) + { + this->discontinuityPlacement = v; + } + + const PointType& getDiscontinuityPlasement() const + { + return this->discontinuityPlacement; + } + + void setLeftDensity( const RealType& leftDensity ) + { + this->leftDensity = leftDensity; + } + + const RealType& getLeftDensity() const + { + return this->leftDensity; + } + + void setRightDensity( const RealType& rightDensity ) + { + this->rightDensity = rightDensity; + } + + const RealType& getRightDensity() const + { + return this->rightDensity; + } + + void setLeftVelocity( const PointType& leftVelocity ) + { + this->leftVelocity = leftVelocity; + } + + const PointType& getLeftVelocity() const + { + return this->leftVelocity; + } + + void setRightVelocity( const RealType& rightVelocity ) + { + this->rightVelocity = rightVelocity; + } + + const PointType& getRightVelocity() const + { + return this->rightVelocity; + } + + void setLeftPressure( const RealType& leftPressure ) + { + this->leftPressure = leftPressure; + } + + const RealType& getLeftPressure() const + { + return this->leftPressure; + } + + void setRightPressure( const RealType& rightPressure ) + { + this->rightPressure = rightPressure; + } + + const RealType& getRightPressure() const + { + return this->rightPressure; + } + + + void predefinedInitialCondition( double preGamma, double preDiscX, double preDiscY, double preDiscZ, + double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ) + + { + this->intensity = 1.0; + this->turbulenceConstant = 1.0; + this->lengthScale = 1.0; + this->discontinuityPlacement = PointLoad(preDiscX, preDiscY, preDiscZ); + this->gamma = preGamma; + + this->NWUDensity = preNWUDensity; + this->NWUVelocity = PointLoad(preNWUVelocityX, preNWUVelocityY, preNWUVelocityZ); + this->NWUPressure = preNWUPressure; + this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); + this->NWUMomentum = NWUVelocity * NWUDensity; + this->NWUTurbulentEnergy = NWUDensity * TurbulentEnergy( NWUVelocity, this->intensity); + this->NWUDisipation = this->turbulenceConstant * std::pow( NWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SWUDensity = preNWUDensity; + this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); + this->SWUPressure = preSWUPressure; + this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); + this->SWUMomentum = SWUVelocity * SWUDensity; + this->SWUTurbulentEnergy = SWUDensity * TurbulentEnergy( SWUVelocity, this->intensity); + this->SWUDisipation = this->turbulenceConstant * std::pow( SWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NWDDensity = preNWDDensity; + this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); + this->NWDPressure = preNWDPressure; + this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); + this->NWDMomentum = NWDVelocity * NWDDensity; + this->NWDTurbulentEnergy = NWDDensity * TurbulentEnergy( NWDVelocity, this->intensity); + this->NWDDisipation = this->turbulenceConstant * std::pow( NWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SWDDensity = preSWDDensity; + this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); + this->SWDPressure = preSWDPressure; + this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); + this->SWDMomentum = SWDVelocity * SWDDensity; + this->SWDTurbulentEnergy = SWDDensity * TurbulentEnergy( SWDVelocity, this->intensity); + this->SWDDisipation = this->turbulenceConstant * std::pow( SWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NEUDensity = preNEUDensity; + this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); + this->NEUPressure = preNEUPressure; + this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); + this->NEUMomentum = NEUVelocity * NEUDensity; + this->NEUTurbulentEnergy = NEUDensity * TurbulentEnergy( NEUVelocity, this->intensity); + this->NEUDisipation = this->turbulenceConstant * std::pow( NEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SEUDensity = preSEUDensity; + this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); + this->SEUPressure = preSEUPressure; + this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); + this->SEUMomentum = SEUVelocity * SEUDensity; + this->SEUTurbulentEnergy = TurbulentEnergy( SEUVelocity, this->intensity); + this->SEUDisipation = this->turbulenceConstant * std::pow( SEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NEDDensity = preNEDDensity; + this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); + this->NEDPressure = preNEDPressure; + this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); + this->NEDMomentum = NEDVelocity * NEDDensity; + this->NEDTurbulentEnergy = NEDDensity * TurbulentEnergy( NEDVelocity, this->intensity); + this->NEDDisipation = this->turbulenceConstant * std::pow( NEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SEDDensity = preSEDDensity; + this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); + this->SEDPressure = preSEDPressure; + this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); + this->SEDMomentum = SEDVelocity * SEDDensity; + this->SEDTurbulentEnergy = SEDDensity * TurbulentEnergy( SEDVelocity, this->intensity); + this->SEDDisipation = this->turbulenceConstant * std::pow( SEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + } + + PointType PointLoad( RealType ValueX, RealType ValueY, RealType ValueZ) + { + PointType point; + switch (Dimensions) + { + case 1: point[ 0 ] = ValueX; + break; + case 2: point[ 0 ] = ValueX; + point[ 1 ] = ValueY; + break; + case 3: point[ 0 ] = ValueX; + point[ 1 ] = ValueY; + point[ 2 ] = ValueZ; + break; + } + return point; + } + + RealType Energy( RealType Density, RealType Pressure, RealType gamma, PointType Velocity) + { + RealType energy; + switch (Dimensions) + { + case 1: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ))); + break; + case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); + break; + case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 2 ], 2 ))); + break; // druhou mocninu ps8t jako sou4in + } + return energy; + } + + RealType TurbulentEnergy( PointType Velocity, RealType intensity ) + { + RealType turbulentEnergy; + switch (Dimensions) + { + case 1: turbulentEnergy = 3.0 / 2.0 * intensity * intensity * ((std::pow(Velocity[ 0 ], 2 ))); + break; + case 2: turbulentEnergy = 3.0 / 2.0 * intensity * intensity * ((std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); + break; + case 3: turbulentEnergy = 3.0 / 2.0 * intensity * intensity * ((std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 2 ], 2 ))); + break; // druhou mocninu ps8t jako sou4in + } + return turbulentEnergy; + } + + void setInitialCondition( CompressibleConservativeVariables< MeshType >& conservativeVariables, + const PointType& center = PointType( 0.0 ) ) + { + RiemannProblemInitialConditionSetter* variablesSetter = new RiemannProblemInitialConditionSetter; + variablesSetter->setGamma(this->gamma); + variablesSetter->setDensity(this->NWUDensity, + this->NEUDensity, + this->SWUDensity, + this->SEUDensity, + this->NWDDensity, + this->NEDDensity, + this->SWDDensity, + this->SEDDensity); + variablesSetter->setMomentum(this->NWUMomentum, + this->NEUMomentum, + this->SWUMomentum, + this->SEUMomentum, + this->NWDMomentum, + this->NEDMomentum, + this->SWDMomentum, + this->SEDMomentum); + variablesSetter->setEnergy(this->NWUEnergy, + this->NEUEnergy, + this->SWUEnergy, + this->SEUEnergy, + this->NWDEnergy, + this->NEDEnergy, + this->SWDEnergy, + this->SEDEnergy); + variablesSetter->setTurbulentEnergy(this->NWUTurbulentEnergy, + this->NEUTurbulentEnergy, + this->SWUTurbulentEnergy, + this->SEUTurbulentEnergy, + this->NWDTurbulentEnergy, + this->NEDTurbulentEnergy, + this->SWDTurbulentEnergy, + this->SEDTurbulentEnergy); + variablesSetter->setDisipation(this->NWUDisipation, + this->NEUDisipation, + this->SWUDisipation, + this->SEUDisipation, + this->NWDDisipation, + this->NEDDisipation, + this->SWDDisipation, + this->SEDDisipation); + variablesSetter->setDiscontinuity(this->discontinuityPlacement); + variablesSetter->placeDensity(conservativeVariables); + variablesSetter->placeMomentum(conservativeVariables); + variablesSetter->placeEnergy(conservativeVariables); + variablesSetter->placeTurbulentEnergy(conservativeVariables); + variablesSetter->placeDisipation(conservativeVariables); + +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + +/* + typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; + typedef Operators::Analytic::Sign< Dimensions, RealType > SignType; + typedef Functions::OperatorFunction< SignType, VectorNormType > InitialConditionType; + typedef SharedPointer< InitialConditionType, DeviceType > InitialConditionPointer; + + InitialConditionPointer initialCondition; + initialCondition->getFunction().setCenter( center ); + initialCondition->getFunction().setMaxNorm( true ); + initialCondition->getFunction().setRadius( discontinuityPlacement[ 0 ] ); + discontinuityPlacement *= 1.0 / discontinuityPlacement[ 0 ]; + for( int i = 1; i < Dimensions; i++ ) + discontinuityPlacement[ i ] = 1.0 / discontinuityPlacement[ i ]; + initialCondition->getFunction().setAnisotropy( discontinuityPlacement ); + initialCondition->getFunction().setMultiplicator( -1.0 ); + + Functions::MeshFunctionEvaluator< MeshFunctionType, InitialConditionType > evaluator; +*/ + /**** + * Density + */ +/* + conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); +*/ +/* + initialCondition->getOperator().setPositiveValue( leftDensity ); + initialCondition->getOperator().setNegativeValue( rightDensity ); + evaluator.evaluate( conservativeVariables.getDensity(), initialCondition ); + conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); +*/ + /**** + * Momentum + */ + +/* + for( int i = 0; i < Dimensions; i++ ) + { + initialCondition->getOperator().setPositiveValue( leftDensity * leftVelocity[ i ] ); + initialCondition->getOperator().setNegativeValue( rightDensity * rightVelocity[ i ] ); + evaluator.evaluate( conservativeVariables.getMomentum()[ i ], initialCondition ); + } +*/ + /**** + * Energy + */ +/* + conservativeVariables.getEnergy()->write( "energy-init", "gnuplot" ); +*/ +/* + const RealType leftKineticEnergy = leftVelocity.lpNorm( 2.0 ); + const RealType rightKineticEnergy = rightVelocity.lpNorm( 2.0 ); + const RealType leftEnergy = leftPressure / ( gamma - 1.0 ) + 0.5 * leftDensity * leftKineticEnergy * leftKineticEnergy; + const RealType rightEnergy = rightPressure / ( gamma - 1.0 ) + 0.5 * rightDensity * rightKineticEnergy * rightKineticEnergy; + initialCondition->getOperator().setPositiveValue( leftEnergy ); + initialCondition->getOperator().setNegativeValue( rightEnergy ); + evaluator.evaluate( (* conservativeVariables.getEnergy()), initialCondition ); + (* conservativeVariables.getEnergy())->write( "energy-init", "gnuplot" ); +*/ + } + + + protected: + + PointType discontinuityPlacement; + PointType NWUVelocity, NEUVelocity, SWUVelocity, SEUVelocity, NWDVelocity, NEDVelocity, SWDVelocity, SEDVelocity; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUPressure, NEUPressure, SWUPressure, SEUPressure, NWDPressure, NEDPressure, SWDPressure, SEDPressure; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + RealType NWUDisipation, NEUDisipation, SWUDisipation, SEUDisipation, NWDDisipation, NEDDisipation, SWDDisipation, SEDDisipation; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + RealType leftDensity, rightDensity; + PointType leftVelocity, rightVelocity; + RealType leftPressure, rightPressure; + + RealType gamma; // gamma in the ideal gas state equation +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/flowsBuildConfigTag.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/flowsBuildConfigTag.h new file mode 100644 index 000000000..c40b793b9 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/flowsBuildConfigTag.h @@ -0,0 +1,72 @@ +#ifndef FLOWSBUILDCONFIGTAG_H_ +#define FLOWSBUILDCONFIGTAG_H_ + +#include +#include + +namespace TNL { + +class flowsBuildConfigTag{}; + +namespace Solvers { + +/**** + * Turn off support for float and long double. + */ +template<> struct ConfigTagReal< flowsBuildConfigTag, float > { enum { enabled = false }; }; +template<> struct ConfigTagReal< flowsBuildConfigTag, long double > { enum { enabled = false }; }; + +/**** + * Turn off support for short int and long int indexing. + */ +template<> struct ConfigTagIndex< flowsBuildConfigTag, short int >{ enum { enabled = false }; }; +template<> struct ConfigTagIndex< flowsBuildConfigTag, long int >{ enum { enabled = false }; }; + +//template< int Dimension > struct ConfigTagDimension< flowsBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; + +/**** + * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. + */ +/*template< int Dimension, typename Real, typename Device, typename Index > + struct ConfigTagMesh< flowsBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > + { enum { enabled = ConfigTagDimension< flowsBuildConfigTag, Dimension >::enabled && + ConfigTagReal< flowsBuildConfigTag, Real >::enabled && + ConfigTagDevice< flowsBuildConfigTag, Device >::enabled && + ConfigTagIndex< flowsBuildConfigTag, Index >::enabled }; }; +*/ +/**** + * Please, chose your preferred time discretisation here. + */ +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; + +/**** + * Only the Runge-Kutta-Merson solver is enabled by default. + */ +template<> struct ConfigTagExplicitSolver< flowsBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; + +} // namespace Solvers + +namespace Meshes { +namespace BuildConfigTags { + +template< int Dimensions > struct GridDimensionTag< flowsBuildConfigTag, Dimensions >{ enum { enabled = true }; }; + +/**** + * Turn off support for float and long double. + */ +template<> struct GridRealTag< flowsBuildConfigTag, float > { enum { enabled = false }; }; +template<> struct GridRealTag< flowsBuildConfigTag, long double > { enum { enabled = false }; }; + +/**** + * Turn off support for short int and long int indexing. + */ +template<> struct GridIndexTag< flowsBuildConfigTag, short int >{ enum { enabled = false }; }; +template<> struct GridIndexTag< flowsBuildConfigTag, long int >{ enum { enabled = false }; }; + +} // namespace BuildConfigTags +} // namespace Meshes +} // namespace TNL + +#endif /* FLOWSBUILDCONFIGTAG_H_ */ diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/flowsRhs.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/flowsRhs.h new file mode 100644 index 000000000..e0b8c7fac --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/flowsRhs.h @@ -0,0 +1,35 @@ +#ifndef FLOWSRHS_H_ +#define FLOWSRHS_H_ + +#include + +namespace TNL { + +template< typename Mesh, typename Real >class flowsRhs + : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > + { + public: + + typedef Mesh MeshType; + typedef Real RealType; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + template< typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshEntity& entity, + const Real& time = 0.0 ) const + { +// typedef typename MeshEntity::MeshType::PointType PointType; +// PointType v = entity.getCenter(); + return 0.0; + } +}; + +} //namespace TNL + +#endif /* FLOWSRHS_H_ */ diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model new file mode 100644 index 000000000..cd0c1bbb1 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-euler-navier-stokes + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --differential-operator Steger-Warming \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-AUSM-plus b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-AUSM-plus new file mode 100644 index 000000000..faaad26b4 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-AUSM-plus @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Ausm-Plus + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Lax-Friedrichs b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Lax-Friedrichs new file mode 100644 index 000000000..5f7bfbdc6 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Lax-Friedrichs @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Lax-Friedrichs + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Steger-Warming b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Steger-Warming new file mode 100644 index 000000000..1c3b5ba65 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Steger-Warming @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Steger-Warming + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Van-Leer b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Van-Leer new file mode 100644 index 000000000..1c3b5ba65 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/run-two-equation-turbulence-model-Van-Leer @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Steger-Warming + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.cpp b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.cpp new file mode 100644 index 000000000..a4f35360f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.cpp @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.cu b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.cu new file mode 100644 index 000000000..a4f35360f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.cu @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.h new file mode 100644 index 000000000..047a44e00 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModel.h @@ -0,0 +1,276 @@ +#include +#include +#include +#include +#include +#include "twoEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/Lax-Friedrichs/LaxFridrichs.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/Steger-Warming/StegerWarming.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/VanLeer/VanLeer.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/AUSM+/AUSMPlus.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class twoEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< String >( "differential-operator", "Choose the differential operator.", "Lax-Friedrichs"); + config.addEntryEnum< String >( "Lax-Friedrichs" ); + config.addEntryEnum< String >( "Steger-Warming" ); + config.addEntryEnum< String >( "VanLeer" ); + config.addEntryEnum< String >( "AUSMPlus" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class twoEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef twoEquationTurbulenceModelOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); + if( differentialOperatorType == "Lax-Friedrichs" ) + { + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "Steger-Warming" ) + { + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "VanLeer" ) + { + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "AUSMPlus" ) + { + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + + + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< twoEquationTurbulenceModelSetter, twoEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.cpp b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.cpp new file mode 100644 index 000000000..c9c751db2 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.cpp @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelAUSMPlus.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.cu b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.cu new file mode 100644 index 000000000..c9c751db2 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.cu @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelAUSMPlus.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.h new file mode 100644 index 000000000..2d831bdb0 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.h @@ -0,0 +1,145 @@ +//#include +#include +#include +#include +#include +#include +#include "twoEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/AUSM+/AUSMPlus.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class twoEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "turbulence-constant", "Value of turbulence constant", 1.0 ); + config.addEntry< double >( "viscosity-constant-1", "Value of viscosity constant C_epsilon_1", 1.0 ); + config.addEntry< double >( "viscosity-constant-2", "Value of viscosity constant C_epsilon_2", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "sigma-epsilon", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); + config.addEntry< double >( "turbulence-length-scale", "meassure of turbulence intensity", 1.0 ); + typedef Meshes::Grid< 3 > Mesh; + AUSMPlus< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class twoEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef KEpsilonOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< twoEquationTurbulenceModelSetter, twoEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.cpp b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.cpp new file mode 100644 index 000000000..0a17eddc7 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.cpp @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelLaxFriedrichs.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.cu b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.cu new file mode 100644 index 000000000..0a17eddc7 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.cu @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelLaxFriedrichs.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.h new file mode 100644 index 000000000..2448756c9 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.h @@ -0,0 +1,145 @@ +//#include +#include +#include +#include +#include +#include +#include "twoEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/Lax-Friedrichs/LaxFridrichs.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class twoEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "turbulence-constant", "Value of turbulence constant", 1.0 ); + config.addEntry< double >( "viscosity-constant-1", "Value of viscosity constant C_epsilon_1", 1.0 ); + config.addEntry< double >( "viscosity-constant-2", "Value of viscosity constant C_epsilon_2", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "sigma-epsilon", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); + config.addEntry< double >( "turbulence-length-scale", "meassure of turbulence intensity", 1.0 ); + typedef Meshes::Grid< 3 > Mesh; + LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class twoEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef KEpsilonOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< twoEquationTurbulenceModelSetter, twoEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem.h new file mode 100644 index 000000000..4b948b3a3 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem.h @@ -0,0 +1,150 @@ +/*************************************************************************** + twoEquationTurbulenceModelProblem.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include "CompressibleConservativeVariables.h" + + +using namespace TNL::Problems; + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +class twoEquationTurbulenceModelProblem: + public PDEProblem< Mesh, + Communicator, + typename InviscidOperators::RealType, + typename Mesh::DeviceType, + typename InviscidOperators::IndexType > +{ + public: + + typedef typename InviscidOperators::RealType RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef typename InviscidOperators::IndexType IndexType; + typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; + + typedef Communicator CommunicatorType; + + using typename BaseType::MeshType; + using typename BaseType::MeshPointer; + using typename BaseType::DofVectorType; + using typename BaseType::DofVectorPointer; + static const int Dimensions = Mesh::getMeshDimension(); + + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; + typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; + typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; + + static String getType(); + + String getPrologHeader() const; + + void writeProlog( Logger& logger, + const Config::ParameterContainer& parameters ) const; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ); + + bool setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ); + + template< typename Matrix > + bool setupLinearSystem( Matrix& matrix ); + + bool makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ); + + IndexType getDofs() const; + + void bindDofs( DofVectorPointer& dofs ); + + void getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ); + + + void applyBoundaryConditions( const RealType& time, + DofVectorPointer& dofs ); + + template< typename Matrix > + void assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs, + Matrix& matrix, + DofVectorPointer& rightHandSide ); + + bool postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ); + + protected: + + InviscidOperatorsPointer inviscidOperatorsPointer; + + BoundaryConditionPointer boundaryConditionPointer; + RightHandSidePointer rightHandSidePointer; + + ConservativeVariablesPointer conservativeVariables, + conservativeVariablesRHS; + + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::ContinuityOperatorType, typename BoundaryCondition::DensityBoundaryConditionsType, RightHandSide > explicitUpdaterContinuity; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumXOperatorType, typename BoundaryCondition::MomentumXBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumX; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumYOperatorType, typename BoundaryCondition::MomentumYBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumY; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumZOperatorType, typename BoundaryCondition::MomentumZBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumZ; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::EnergyOperatorType, typename BoundaryCondition::EnergyBoundaryConditionsType, RightHandSide > explicitUpdaterEnergy; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::TurbulentEnergyOperatorType, typename BoundaryCondition::TurbulentEnergyBoundaryConditionsType, RightHandSide > explicitUpdaterTurbulentEnergy; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::DisipationOperatorType, typename BoundaryCondition::DisipationBoundaryConditionsType, RightHandSide > explicitUpdaterDisipation; + + + VelocityFieldPointer velocity; + MeshFunctionPointer pressure; + MeshFunctionPointer turbulentViscosity; + MeshFunctionPointer turbulentEnergy; + MeshFunctionPointer disipation; + + RealType gamma; + RealType speedIncrement; + RealType cavitySpeed; + RealType speedIncrementUntil; + RealType finalSpeed; + RealType startSpeed; + RealType speedIncrementUntilHThrottle; + RealType finalSpeedHThrottle; + RealType startSpeedHThrottle; + RealType turbulenceConstant; + RealType sigmaK; + RealType sigmaEpsilon; + RealType viscosityConstant1; + RealType viscosityConstant2; + RealType intensity; + RealType lengthScale; +}; + +} // namespace TNL + +#include "twoEquationTurbulenceModelProblem_impl.h" + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem_impl.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem_impl.h new file mode 100644 index 000000000..bc7594fb5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem_impl.h @@ -0,0 +1,566 @@ +/*************************************************************************** + twoEquationTurbulenceModelProblem_impl.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "RiemannProblemInitialCondition.h" +#include "CompressibleConservativeVariables.h" +#include "PhysicalVariablesGetter.h" +#include "twoEquationTurbulenceModelProblem.h" + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getType() +{ + return String( "twoEquationTurbulenceModelProblem< " ) + Mesh :: getType() + " >"; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getPrologHeader() const +{ + return String( "flow solver" ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const +{ + /**** + * Add data you want to have in the computation report (log) as follows: + * logger.writeParameter< double >( "Parameter description", parameter ); + */ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setup( const Config::ParameterContainer& parameters, + const String& prefix ) +{ + if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || + ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || + ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) + return false; + this->gamma = parameters.getParameter< double >( "gamma" ); + this->startSpeed = parameters.getParameter< double >( "start-speed" ); + this->finalSpeed = parameters.getParameter< double >( "final-speed" ); + this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); + this->startSpeedHThrottle = parameters.getParameter< double >( "start-speed-h-throttle" ); + this->finalSpeedHThrottle = parameters.getParameter< double >( "final-speed-h-throttle" ); + this->speedIncrementUntilHThrottle = parameters.getParameter< RealType >( "speed-increment-until-h-throttle" ); + this->turbulenceConstant = parameters.getParameter< double >( "turbulence-constant" ); + this->viscosityConstant1 = parameters.getParameter< double >( "viscosity-constant-1" ); + this->viscosityConstant2 = parameters.getParameter< double >( "viscosity-constant-2" ); + this->sigmaK = parameters.getParameter< double >( "sigma-k" ); + this->sigmaEpsilon = parameters.getParameter< double >( "sigma-epsilon" ); + this->intensity = parameters.getParameter< double >( "turbulence-intensity" ); + this->lengthScale = parameters.getParameter< double >( "length-scale" ); + velocity->setMesh( this->getMesh() ); + pressure->setMesh( this->getMesh() ); + + /**** + * Set-up operators + */ + + this->inviscidOperatorsPointer->setSigmaK( this->sigmaK ); + this->inviscidOperatorsPointer->setSigmaEpsilon( this->sigmaEpsilon ); + this->inviscidOperatorsPointer->setViscosityConstant1( this->viscosityConstant1 ); + this->inviscidOperatorsPointer->setViscosityConstant2( this->viscosityConstant2 ); + this->inviscidOperatorsPointer->setDisipation( this->disipation ); + this->inviscidOperatorsPointer->setVelocity( this->velocity ); + this->inviscidOperatorsPointer->setPressure( this->pressure ); + this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); + this->inviscidOperatorsPointer->setGamma( this->gamma ); + this->inviscidOperatorsPointer->setTurbulentViscosity( this->turbulentViscosity ); + this->inviscidOperatorsPointer->setTurbulentEnergy( this->turbulentEnergy ); + + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); + this->explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer->getDensityBoundaryCondition() ); + this->explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); + + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); + this->explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer->getMomentumXBoundaryCondition() ); + this->explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); + + if( Dimensions > 1 ) + { + this->explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); + this->explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer->getMomentumYBoundaryCondition() ); + this->explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); + this->explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer->getMomentumZBoundaryCondition() ); + this->explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); + this->explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer->getEnergyBoundaryCondition() ); + this->explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); + + /**** + * Turbulent energy equation + */ + this->explicitUpdaterTurbulentEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getTurbulentEnergyOperator() ); + this->explicitUpdaterTurbulentEnergy.setBoundaryConditions( this->boundaryConditionPointer->getTurbulentEnergyBoundaryCondition() ); + this->explicitUpdaterTurbulentEnergy.setRightHandSide( this->rightHandSidePointer ); + + /**** + * Disipation equation + */ + this->explicitUpdaterDisipation.setDifferentialOperator( this->inviscidOperatorsPointer->getDisipationOperator() ); + this->explicitUpdaterDisipation.setBoundaryConditions( this->boundaryConditionPointer->getDisipationBoundaryCondition() ); + this->explicitUpdaterDisipation.setRightHandSide( this->rightHandSidePointer ); + + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +typename twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >::IndexType +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getDofs() const +{ + /**** + * Return number of DOFs (degrees of freedom) i.e. number + * of unknowns to be resolved by the main solver. + */ + return this->conservativeVariables->getDofs( this->getMesh() ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +bindDofs( DofVectorPointer& dofVector ) +{ + this->conservativeVariables->bind( this->getMesh(), dofVector ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ) +{ + CompressibleConservativeVariables< MeshType > conservativeVariables; + conservativeVariables.bind( this->getMesh(), dofs ); + const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); + this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); + this->speedIncrement = parameters.getParameter< RealType >( "speed-increment" ); + this->cavitySpeed = parameters.getParameter< RealType >( "cavity-speed" ); + if( initialConditionType == "riemann-problem" ) + { + RiemannProblemInitialCondition< MeshType > initialCondition; + if( ! initialCondition.setup( parameters ) ) + return false; + initialCondition.setInitialCondition( conservativeVariables ); + return true; + } + std::cerr << "Unknown initial condition " << initialConditionType << std::endl; + return false; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +bool +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setupLinearSystem( Matrix& matrix ) +{ +/* const IndexType dofs = this->getDofs(); + typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; + CompressedRowLengthsVectorType rowLengths; + if( ! rowLengths.setSize( dofs ) ) + return false; + MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; + matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, + differentialOperator, + boundaryCondition, + rowLengths ); + matrix.setDimensions( dofs, dofs ); + if( ! matrix.setCompressedRowLengths( rowLengths ) ) + return false;*/ + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ) +{ + std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; + + this->bindDofs( dofs ); + PhysicalVariablesGetter< MeshType > physicalVariablesGetter; + physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + + FileName fileName; + fileName.setExtension( "tnl" ); + fileName.setIndex( step ); + fileName.setFileNameBase( "density-" ); +// if( ! this->conservativeVariables->getDensity()->save( fileName.getFileName() ) ) + this->conservativeVariables->getDensity()->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "velocity-" ); +// if( ! this->velocity->save( fileName.getFileName() ) ) + this->velocity->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "pressure-" ); +// if( ! this->pressure->save( fileName.getFileName() ) ) + this->pressure->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "energy-" ); +// if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) + this->conservativeVariables->getEnergy()->save( fileName.getFileName() ); +// return false; + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ) +{ + typedef typename MeshType::Cell Cell; + + /**** + * Bind DOFs + */ + this->conservativeVariables->bind( this->getMesh(), _u ); + this->conservativeVariablesRHS->bind( this->getMesh(), _fu ); + + /**** + * Resolve the physical variables + */ + PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; + physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + physicalVariables.getTurbulentEnergy( this->conservativeVariables, this->turbulentEnergy ); + physicalVariables.getDisipation( this->conservativeVariables, this->disipation ); + physicalVariables.getTurbulentViscosity( this->conservativeVariables, this->turbulentEnergy, this->disipation, this->turbulenceConstant, this->turbulentViscosity ); + + /**** + * Set-up operators + */ + + this->inviscidOperatorsPointer->setTau( tau ); + + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getDensity(), + this->conservativeVariablesRHS->getDensity() ); + +// this->explicitUpdaterContinuity.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, +// this->conservativeVariables->getDensity() ); + + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); + if( Dimensions > 1 ) + { + this->explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getEnergy(), // uRhoVelocityX, + this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); + + + /**** + * Turbulent energy equation + */ + this->explicitUpdaterTurbulentEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getTurbulentEnergy(), // uRhoVelocityX, + this->conservativeVariablesRHS->getTurbulentEnergy() ); //, fuRhoVelocityX ); + + /**** + * Disipation equation + */ + this->explicitUpdaterTurbulentEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getDisipation(), // uRhoVelocityX, + this->conservativeVariablesRHS->getDisipation() ); //, fuRhoVelocityX ); + + /*this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); + this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); + this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); + getchar();*/ + +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +applyBoundaryConditions( const RealType& time, + DofVectorPointer& dofs ) +{ + /**** + * Update Boundary Conditions + */ + if(this->speedIncrementUntil > time ) + { + this->boundaryConditionPointer->setTimestep(this->speedIncrement); + } + else + { + this->boundaryConditionPointer->setTimestep(0); + } + this->boundaryConditionPointer->setIntensity(this->intensity); + this->boundaryConditionPointer->setLengthScale(this->lengthScale); + this->boundaryConditionPointer->setTurbulenceConstant(this->turbulenceConstant); + this->boundaryConditionPointer->setSpeed(this->cavitySpeed); + this->boundaryConditionPointer->setCompressibleConservativeVariables(this->conservativeVariables); + this->boundaryConditionPointer->setGamma(this->gamma); + this->boundaryConditionPointer->setPressure(this->pressure); + this->boundaryConditionPointer->setVerticalThrottleSpeed( startSpeed, finalSpeed, time, speedIncrementUntil ); + this->boundaryConditionPointer->setHorizontalThrottleSpeed( startSpeedHThrottle, finalSpeedHThrottle, time, speedIncrementUntilHThrottle ); + /**** + * Bind DOFs + */ + this->conservativeVariables->bind( this->getMesh(), dofs ); +// this->conservativeVariables->getDensity()->write( "density", "gnuplot" ); +// this->conservativeVariables->getEnergy()->write( "energy", "gnuplot" ); +// this->conservativeVariables->getMomentum()->write( "momentum", "gnuplot", 0.05 ); +// dofs->save("dofs.tnl"); +// getchar(); +// std::cout <<"applyBCC" << std::endl; + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getDensity() ); + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 0 ] ); // uRhoVelocityX, + if( Dimensions > 1 ) + { + + this->explicitUpdaterMomentumY.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 1 ] ); // uRhoVelocityX, + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 2 ] ); // uRhoVelocityX, + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getEnergy() ); // uRhoVelocityX, + + /**** + * Turbulent energy equation + */ + this->explicitUpdaterTurbulentEnergy.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getTurbulentEnergy() ); // uRhoVelocityX, + /**** + * Turbulent energy equation + */ + this->explicitUpdaterDisipation.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getDisipation() ); // uRhoVelocityX, + + +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +void +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + Matrix& matrix, + DofVectorPointer& b ) +{ +/* LinearSystemAssembler< Mesh, + MeshFunctionType, + InviscidOperators, + BoundaryCondition, + RightHandSide, + BackwardTimeDiscretisation, + Matrix, + DofVectorType > systemAssembler; + + MeshFunction< Mesh > u( mesh, _u ); + systemAssembler.template assembly< typename Mesh::Cell >( time, + tau, + this->differentialOperator, + this->boundaryCondition, + this->rightHandSide, + u, + matrix, + b );*/ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ) +{ + /* + typedef typename MeshType::Cell Cell; + int count = mesh->template getEntitiesCount< Cell >()/4; + //bind _u + this->_uRho.bind( *dofs, 0, count); + this->_uRhoVelocityX.bind( *dofs, count, count); + this->_uRhoVelocityY.bind( *dofs, 2 * count, count); + this->_uEnergy.bind( *dofs, 3 * count, count); + + MeshFunctionType velocity( mesh, this->velocity ); + MeshFunctionType velocityX( mesh, this->velocityX ); + MeshFunctionType velocityY( mesh, this->velocityY ); + MeshFunctionType pressure( mesh, this->pressure ); + MeshFunctionType uRho( mesh, _uRho ); + MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); + MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); + MeshFunctionType uEnergy( mesh, _uEnergy ); + //Generating differential operators + Velocity euler2DVelocity; + VelocityX euler2DVelocityX; + VelocityY euler2DVelocityY; + Pressure euler2DPressure; + + //velocityX + euler2DVelocityX.setRhoVelX(uRhoVelocityX); + euler2DVelocityX.setRho(uRho); +// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; +// velocityX = OFVelocityX; + + //velocityY + euler2DVelocityY.setRhoVelY(uRhoVelocityY); + euler2DVelocityY.setRho(uRho); +// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; +// velocityY = OFVelocityY; + + //velocity + euler2DVelocity.setVelX(velocityX); + euler2DVelocity.setVelY(velocityY); +// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; +// velocity = OFVelocity; + + //pressure + euler2DPressure.setGamma(gamma); + euler2DPressure.setVelocity(velocity); + euler2DPressure.setEnergy(uEnergy); + euler2DPressure.setRho(uRho); +// OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure; +// pressure = OFPressure; + */ + return true; +} + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.cpp b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.cpp new file mode 100644 index 000000000..30a2938a7 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.cpp @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelStegerWarming.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.cu b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.cu new file mode 100644 index 000000000..30a2938a7 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.cu @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelStegerWarming.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.h new file mode 100644 index 000000000..efcb66351 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.h @@ -0,0 +1,145 @@ +//#include +#include +#include +#include +#include +#include +#include "twoEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/Steger-Warming/StegerWarming.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class twoEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "turbulence-constant", "Value of turbulence constant", 1.0 ); + config.addEntry< double >( "viscosity-constant-1", "Value of viscosity constant C_epsilon_1", 1.0 ); + config.addEntry< double >( "viscosity-constant-2", "Value of viscosity constant C_epsilon_2", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "sigma-epsilon", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); + config.addEntry< double >( "turbulence-length-scale", "meassure of turbulence intensity", 1.0 ); + typedef Meshes::Grid< 3 > Mesh; + StegerWarming< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class twoEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef KEpsilonOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< twoEquationTurbulenceModelSetter, twoEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.cpp b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.cpp new file mode 100644 index 000000000..2bd33e16a --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.cpp @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelVanLeer.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.cu b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.cu new file mode 100644 index 000000000..a4f35360f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.cu @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.h new file mode 100644 index 000000000..7dd9821c5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.h @@ -0,0 +1,145 @@ +//#include +#include +#include +#include +#include +#include +#include "twoEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/VanLeer/VanLeer.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class twoEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "turbulence-constant", "Value of turbulence constant", 1.0 ); + config.addEntry< double >( "viscosity-constant-1", "Value of viscosity constant C_epsilon_1", 1.0 ); + config.addEntry< double >( "viscosity-constant-2", "Value of viscosity constant C_epsilon_2", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "sigma-epsilon", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); + config.addEntry< double >( "turbulence-length-scale", "meassure of turbulence intensity", 1.0 ); + typedef Meshes::Grid< 3 > Mesh; + VanLeer< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class twoEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef KEpsilonOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< twoEquationTurbulenceModelSetter, twoEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h new file mode 100644 index 000000000..0709bc3b9 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h @@ -0,0 +1,190 @@ +#include + +#include "DensityBoundaryConditionBoiler.h" +#include "MomentumXBoundaryConditionBoiler.h" +#include "MomentumYBoundaryConditionBoiler.h" +#include "MomentumZBoundaryConditionBoiler.h" +#include "EnergyBoundaryConditionBoiler.h" +#include "TurbulentEnergyBoundaryConditionBoiler.h" +#include "DisipationBoundaryConditionBoiler.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsBoiler +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::TurbulentEnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef TNL::Operators::DisipationBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > DisipationBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< DisipationBoundaryConditionsType > DisipationBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->disipationBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->turbulentEnergyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->disipationBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + } + + void setIntensity(const RealType& intensity) + { + this->turbulentEnergyBoundaryConditionsPointer->setIntensity( intensity ); + this->disipationBoundaryConditionsPointer->setIntensity( intensity ); + } + + void setLengthScale( const RealType& lengthScale ) + { + this->disipationBoundaryConditionsPointer->setLengthScale ( lengthScale ); + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->disipationBoundaryConditionsPointer->setTurbulenceConstant ( turbulenceConstant ); + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + DisipationBoundaryConditionsTypePointer& getDisipationBoundaryCondition() + { + return this->disipationBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + DisipationBoundaryConditionsTypePointer disipationBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h new file mode 100644 index 000000000..6231f6780 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h @@ -0,0 +1,542 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().y() < 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().z() < 0.8 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionBoilers: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h new file mode 100644 index 000000000..a94af83b6 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h @@ -0,0 +1,718 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DisipationBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function> +class DisipationBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DisipationBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h new file mode 100644 index 000000000..412640b54 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h @@ -0,0 +1,853 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + + + this->cavitySpeed + * + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) +{ + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * + ( + ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( + this->cavitySpeed + * + this->cavitySpeed + ) + ); + + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h new file mode 100644 index 000000000..dfe63e076 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h @@ -0,0 +1,594 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h new file mode 100644 index 000000000..83b6282dd --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h @@ -0,0 +1,588 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h new file mode 100644 index 000000000..9d887857c --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h @@ -0,0 +1,563 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h new file mode 100644 index 000000000..e6b63da71 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/TurbulentEnergyBoundaryConditionBoiler.h @@ -0,0 +1,664 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class TurbulentEnergyBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function> +class TurbulentEnergyBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const TurbulentEnergyBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h new file mode 100644 index 000000000..44e2b9531 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h @@ -0,0 +1,237 @@ +#include + +#include "DensityBoundaryConditionBoilerModel.h" +#include "MomentumXBoundaryConditionBoilerModel.h" +#include "MomentumYBoundaryConditionBoilerModel.h" +#include "MomentumZBoundaryConditionBoilerModel.h" +#include "EnergyBoundaryConditionBoilerModel.h" +#include "TurbulentEnergyBoundaryConditionBoilerModel.h" +#include "DisipationBoundaryConditionBoilerModel.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsBoilerModel +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef TNL::Operators::DisipationBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > DisipationBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< DisipationBoundaryConditionsType > DisipationBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "vertical-angle", "Vertical angle of throttle in degrees", 0 ); + config.addEntry< double >( prefix + "horizontal-angle", "Horizontal angle of throttle in degrees", 45 ); + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + setZAngle(parameters.getParameter< double >( prefix + "vertical-angle" ) * M_PI / 180.0 ); + setXYAngle(parameters.getParameter< double >( prefix + "horizontal-angle" ) * M_PI / 180.0 ); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->turbulentEnergyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->disipationBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setZAngle(const RealType zAngle) + { + this->densityBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumXBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumYBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumZBoundaryConditionsPointer->setZAngle(zAngle); + this->energyBoundaryConditionsPointer->setZAngle(zAngle); + this->turbulentEnergyBoundaryConditionsPointer->setZAngle(zAngle); + this->disipationBoundaryConditionsPointer->setZAngle(zAngle); + } + + void setXYAngle(const RealType xYAngle) + { + this->densityBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumXBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumYBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumZBoundaryConditionsPointer->setXYAngle(xYAngle); + this->turbulentEnergyBoundaryConditionsPointer->setXYAngle(xYAngle); + this->disipationBoundaryConditionsPointer->setXYAngle(xYAngle); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setIntensity(const RealType& intensity) + { + this->turbulentEnergyBoundaryConditionsPointer->setIntensity( intensity ); + this->disipationBoundaryConditionsPointer->setIntensity( intensity ); + } + + void setLengthScale( const RealType& lengthScale ) + { + this->disipationBoundaryConditionsPointer->setLengthScale ( lengthScale ); + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->disipationBoundaryConditionsPointer->setTurbulenceConstant ( turbulenceConstant ); + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + RealType horizontalThrottleSpeed = 0; + if(time <= finalTime) + if( time != 0 && finalTime != 0 ) + horizontalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) * ( time / finalTime ); + else + horizontalThrottleSpeed = 0; + else + horizontalThrottleSpeed = finalSpeed; + this->momentumXBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->momentumYBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->momentumZBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->energyBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->turbulentEnergyBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->disipationBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + RealType verticalThrottleSpeed = 0; + if(time <= finalTime) + if( time != 0 && finalTime != 0 ) + verticalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) * ( time / finalTime ); + else + verticalThrottleSpeed = 0; + else + verticalThrottleSpeed = finalSpeed; + this->momentumXBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->momentumYBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->momentumZBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->energyBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->turbulentEnergyBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->disipationBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + DisipationBoundaryConditionsTypePointer& getDisipationBoundaryCondition() + { + return this->disipationBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + DisipationBoundaryConditionsTypePointer disipationBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..a58f32f7c --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h @@ -0,0 +1,580 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().y() < 0.835 * ( entity.getMesh().getDimensions().y() - 1 )) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + // if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..b3f585a9e --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h @@ -0,0 +1,892 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DisipationBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function> +class DisipationBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle Disipation + { + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + }; + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle Disipation + { + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + } +// if for chimney exit + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DisipationBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DisipationBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ +const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; +// if for chimney exit + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) +// &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DisipationBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..d0475576b --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h @@ -0,0 +1,962 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle energy + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + }; + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle energy + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + if( (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] != 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * ( ( (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + ) + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + ); + else return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->verticalThrottleSpeed + * + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ +const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; +// if for chimney exit + } + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + if( (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] != 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * ( ( (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 2 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 2 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + ) + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + ); + else return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) +// &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->verticalThrottleSpeed + * + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..65648c389 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -0,0 +1,940 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +//throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->zAngle ) + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->zAngle ) + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..e8aa33e88 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h @@ -0,0 +1,941 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +//throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( - 1.0 ) + * std::sin( this->zAngle ) + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) +// down throttle + { + if( + ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) + ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->verticalThrottleSpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..625b74585 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -0,0 +1,838 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( + ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..851b70618 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/TurbulentEnergyBoundaryConditionBoilerModel.h @@ -0,0 +1,832 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class TurbulentEnergyBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function> +class TurbulentEnergyBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle TurbulentEnergy + { + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + }; + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle TurbulentEnergy + { + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + } +// if for chimney exit + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef TurbulentEnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef TurbulentEnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ +const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed;; + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; +// if for chimney exit + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed; + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed;; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) +// &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed;; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + RealType intensity; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const TurbulentEnergyBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h new file mode 100644 index 000000000..e2adc7424 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h @@ -0,0 +1,193 @@ +#include + +#include "DensityBoundaryConditionCavity.h" +#include "MomentumXBoundaryConditionCavity.h" +#include "MomentumYBoundaryConditionCavity.h" +#include "MomentumZBoundaryConditionCavity.h" +#include "EnergyBoundaryConditionCavity.h" +#include "TurbulentEnergyBoundaryConditionCavity.h" +#include "DisipationBoundaryConditionCavity.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsCavity +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::TurbulentEnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef TNL::Operators::DisipationBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > DisipationBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< DisipationBoundaryConditionsType > DisipationBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->turbulentEnergyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->disipationBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->turbulentEnergyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->disipationBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->turbulentEnergyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->disipationBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + } + + void setIntensity(const RealType& intensity) + { + this->turbulentEnergyBoundaryConditionsPointer->setIntensity( intensity ); + this->disipationBoundaryConditionsPointer->setIntensity( intensity ); + } + + void setLengthScale( const RealType& lengthScale ) + { + this->disipationBoundaryConditionsPointer->setLengthScale ( lengthScale ); + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->disipationBoundaryConditionsPointer->setTurbulenceConstant ( turbulenceConstant ); + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + DisipationBoundaryConditionsTypePointer& getDisipationBoundaryCondition() + { + return this->disipationBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + DisipationBoundaryConditionsTypePointer disipationBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h new file mode 100644 index 000000000..c753d324a --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h @@ -0,0 +1,536 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 1, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 1 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h new file mode 100644 index 000000000..acee185a2 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h @@ -0,0 +1,610 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DisipationBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function> +class DisipationBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DisipationBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DisipationBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return this->turbulenceConstant + * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + / this->lengthScale; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + void setLengthScale( const RealType& lengthScale ) + { + this->lengthScale = lengthScale; + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + this->turbulenceConstant = turbulenceConstant; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DisipationBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h new file mode 100644 index 000000000..ca5d85442 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h @@ -0,0 +1,672 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< 1, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< -1, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + ); + } + if( entity.getCoordinates().y() == 0 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 1 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + ); + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, -1 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + * ( + this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + * + this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + * + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h new file mode 100644 index 000000000..07abfdbeb --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h @@ -0,0 +1,570 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + * ( + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + ); + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h new file mode 100644 index 000000000..a83dd653f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h @@ -0,0 +1,564 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h new file mode 100644 index 000000000..5fe6f22e5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h @@ -0,0 +1,554 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h new file mode 100644 index 000000000..05098c7dd --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/TurbulentEnergyBoundaryConditionCavity.h @@ -0,0 +1,568 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class TurbulentEnergyBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function> +class TurbulentEnergyBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class TurbulentEnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public TurbulentEnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + void setIntensity( const RealType& intensity ) + { + this->intensity = intensity; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + RealType intensity; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const TurbulentEnergyBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h new file mode 100644 index 000000000..8a93fd2fc --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h @@ -0,0 +1,159 @@ +#include +#include +#include +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Function = Functions::Analytic::Constant< Mesh::getMeshDimension(), typename Mesh::RealType >, + int MeshEntitiesDimension = Mesh::getMeshDimension(), + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class BoundaryConditionsDirichlet +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > DisipationBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< DisipationBoundaryConditionsType > DisipationBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + + } + + void setTimestep(const RealType timestep) + { + + } + + void setGamma(const RealType gamma) + { + + } + + void setPressure(const MeshFunctionPointer& pressure) + { + + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setIntensity(const RealType& intensity) + { + + } + + void setLengthScale( const RealType& lengthScale ) + { + + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + DisipationBoundaryConditionsTypePointer& getDisipationBoundaryCondition() + { + return this->disipationBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + DisipationBoundaryConditionsTypePointer disipationBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h new file mode 100644 index 000000000..bc6c4bdec --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h @@ -0,0 +1,155 @@ +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class BoundaryConditionsNeumann +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > TurbulentEnergyBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > DisipationBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< TurbulentEnergyBoundaryConditionsType > TurbulentEnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< DisipationBoundaryConditionsType > DisipationBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + + } + + void setTimestep(const RealType timestep) + { + + } + + void setGamma(const RealType gamma) + { + + } + + void setPressure(const MeshFunctionPointer& pressure) + { + + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setIntensity(const RealType& intensity) + { + + } + + void setLengthScale( const RealType& lengthScale ) + { + + } + + void setTurbulenceConstant( const RealType& turbulenceConstant ) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + TurbulentEnergyBoundaryConditionsTypePointer& getTurbulentEnergyBoundaryCondition() + { + return this->turbulentEnergyBoundaryConditionsPointer; + } + + DisipationBoundaryConditionsTypePointer& getDisipationBoundaryCondition() + { + return this->disipationBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + TurbulentEnergyBoundaryConditionsTypePointer turbulentEnergyBoundaryConditionsPointer; + DisipationBoundaryConditionsTypePointer disipationBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists.txt b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists.txt new file mode 100644 index 000000000..0c170893b --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists.txt @@ -0,0 +1,101 @@ +#k-omega-Lax-Friedrichs + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + twoEquationTurbulenceModelLaxFriedrichs.cpp + twoEquationTurbulenceModelLaxFriedrichs.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-k-omega-Lax-Friedrichs twoEquationTurbulenceModelLaxFriedrichs.cu) + target_link_libraries (tnl-k-omega-Lax-Friedrichs ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-k-omega-Lax-Friedrichs twoEquationTurbulenceModelLaxFriedrichs.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-k-omega-Lax-Friedrichs + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-two-equation-turbulence-model-Lax-Friedrichs + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#k-omega-Steger-Warming + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + twoEquationTurbulenceModelStegerWarming.cpp + twoEquationTurbulenceModelStegerWarming.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-k-omega-Steger-Warming twoEquationTurbulenceModelStegerWarming.cu) + target_link_libraries (tnl-k-omega-Steger-Warming ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-k-omega-Steger-Warming twoEquationTurbulenceModelStegerWarming.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-k-omega-Steger-Warming + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-two-equation-turbulence-model-Steger-Warming + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#k-omega-Van-Leer + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + twoEquationTurbulenceModelVanLeer.cpp + twoEquationTurbulenceModelVanLeer.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-k-omega-Van-Leer twoEquationTurbulenceModelVanLeer.cu) + target_link_libraries (tnl-k-omega-Van-Leer ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-k-omega-Van-Leer twoEquationTurbulenceModelVanLeer.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-k-omega-Van-Leer + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-two-equation-turbulence-model-Van-Leer + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#k-omega-AUSM-plus + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + twoEquationTurbulenceModelAUSMPlus.cpp + twoEquationTurbulenceModelAUSMPlus.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-k-omega-AUSM-plus twoEquationTurbulenceModelAUSMPlus.cu) + target_link_libraries (tnl-k-omega-AUSM-plus ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-k-omega-AUSM-plus twoEquationTurbulenceModelAUSMPlus.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-k-omega-AUSM-plus + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-two-equation-turbulence-model-AUSM-plus + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists_separate.txt b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists_separate.txt new file mode 100644 index 000000000..cd8e6f870 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists_separate.txt @@ -0,0 +1,101 @@ +#navier-stokes-Lax-Friedrichs + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesLaxFriedrichs.cpp + navierStokesLaxFriedrichs.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cu) + target_link_libraries (tnl-navier-stokes-Lax-Friedrichs ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Lax-Friedrichs + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Lax-Friedrichs + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Steger-Warming + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesStegerWarming.cpp + navierStokesStegerWarming.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cu) + target_link_libraries (tnl-navier-stokes-Steger-Warming ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Steger-Warming + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Steger-Warming + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Van-Leer + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesVanLeer.cpp + navierStokesVanLeer.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cu) + target_link_libraries (tnl-navier-stokes-Van-Leer ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Van-Leer + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Van-Leer + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-AUSM-plus + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesAUSMPlus.cpp + navierStokesAUSMPlus.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cu) + target_link_libraries (tnl-navier-stokes-AUSM-plus ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-AUSM-plus + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-AUSM-plus + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists_together.txt b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists_together.txt new file mode 100644 index 000000000..f26fc6d34 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CMakeLists_together.txt @@ -0,0 +1,26 @@ +#navier-stokes + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokes.cpp + navierStokes.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cu) + target_link_libraries (tnl-navier-stokes ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CompressibleConservativeVariables.h new file mode 100644 index 000000000..a6c4a7591 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/CompressibleConservativeVariables.h @@ -0,0 +1,202 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ), + turbulentEnergy( meshPointer ), + disipation( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + this->turbulentEnergy->setMesh( meshPointer ); + this->disipation->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + currentOffset += this->energy->getDofs( meshPointer ); + this->turbulentEnergy->bind( meshPointer, data, currentOffset ); + currentOffset += this->turbulentEnergy->getDofs( meshPointer ); + this->disipation->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ) + + this->turbulentEnergy->getDofs( meshPointer ) + + this->disipation->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + __cuda_callable__ + MeshFunctionPointer& getTurbulentEnergy() + { + return this->turbulentEnergy; + } + + __cuda_callable__ + const MeshFunctionPointer& getTurbulentEnergy() const + { + return this->turbulentEnergy; + } + + void setTurbulentEnergy( MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + __cuda_callable__ + MeshFunctionPointer& getDisipation() + { + return this->disipation; + } + + __cuda_callable__ + const MeshFunctionPointer& getDisipation() const + { + return this->disipation; + } + + void setDisipation( MeshFunctionPointer& disipation ) + { + this->disipation = disipation; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + MeshFunctionPointer turbulentEnergy; + MeshFunctionPointer disipation; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h new file mode 100644 index 000000000..e74d0e5d4 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h @@ -0,0 +1,252 @@ +/*************************************************************************** + AUSMPlus.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "AUSMPlusContinuity.h" +#include "AUSMPlusEnergy.h" +#include "AUSMPlusMomentumX.h" +#include "AUSMPlusMomentumY.h" +#include "AUSMPlusMomentumZ.h" +#include "AUSMPlusTurbulentEnergy.h" +#include "AUSMPlusDisipation.h" + +#include "Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = KOmegaOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlus +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::DisipationOperatorRightHandSideType DisipationOperatorRightHandSideType; + + typedef AUSMPlusContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef AUSMPlusMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef AUSMPlusMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef AUSMPlusMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef AUSMPlusEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef AUSMPlusTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + typedef AUSMPlusDisipation< Mesh, DisipationOperatorRightHandSideType, Real, Index > DisipationOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + typedef Pointers::SharedPointer< DisipationOperatorType > DisipationOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + AUSMPlus() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "AUSMPlus" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->disipationOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + this->disipationOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + this->turbulentEnergyOperatorPointer->setGamma( gamma ); + this->disipationOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + this->turbulentEnergyOperatorPointer->setPressure( pressure ); + this->disipationOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + this->turbulentEnergyOperatorPointer->setDensity( density ); + this->disipationOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + this->disipationOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->disipationOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->disipationOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->disipationOperatorPointer->setSigmaEpsilon( sigmaEpsilon ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->disipationOperatorPointer->setDisipation( disipation ); + this->turbulentEnergyOperatorPointer->setDisipation( disipation ); + } + + void setBeta( const RealType& beta ) + { + this->disipationOperatorPointer->setBeta( beta ); + } + + void setAlpha( const RealType& alpha ) + { + this->disipationOperatorPointer->setAlpha( alpha ); + } + + void setBetaStar( const RealType& betaStar ) + { + this->turbulentEnergyOperatorPointer->setBetaStar( betaStar ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + const DisipationOperatorPointer& getDisipationOperator() const + { + return this->disipationOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + DisipationOperatorPointer disipationOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h new file mode 100644 index 000000000..2d92e9dc8 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h @@ -0,0 +1,401 @@ +/*************************************************************************** + AUSMPlusContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "AUSMPlusContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType DensityFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity + MachBorderMinus * RightDensity ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return hxInverse * ( + this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return hxInverse * ( + this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->DensityFlux( u[ north ], u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) + - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return hxInverse * ( + this->DensityFlux( u[ west ] , u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->DensityFlux( u[ north ] , u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) + - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + ) + + hzInverse * ( + this->DensityFlux( u[ up ] , u[ center ], velocity_z_up , velocity_z_center, pressure_up , pressure_center ) + - this->DensityFlux( u[ center ], u[ down ] , velocity_z_center, velocity_z_down , pressure_center, pressure_down ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h new file mode 100644 index 000000000..09a4469c4 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h @@ -0,0 +1,465 @@ +/*************************************************************************** + AUSMPlusDisipation.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusDisipationBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "AUSMPlusDisipation< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity( velocity ); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + this->rightHandSide.setDensity( density ); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity( turbulentViscosity ); + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity( dynamicalViscosity ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->rightHandSide.setSigmaEpsilon( sigmaEpsilon ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy( turbulentEnergy ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + } + + void setBeta( const RealType& beta ) + { + this->rightHandSide.setBeta( beta ); + } + + void setAlpha( const RealType& alpha ) + { + this->rightHandSide.setAlpha( alpha ); + } + + RealType DisipationFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure, + const RealType& LeftDisipation, + const RealType& RightDisipation ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDisipation + MachBorderMinus * RightDisipation ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusDisipation +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusDisipation< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusDisipationBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return hxInverse * ( + this->DisipationFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->DisipationFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusDisipation< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusDisipationBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return hxInverse * ( + this->DisipationFlux( density_west , density_center , velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->DisipationFlux( density_center , density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->DisipationFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ], u[ center ] ) + - this->DisipationFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusDisipation< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusDisipationBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return hxInverse * ( + this->DisipationFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ] , u[ center ] ) + - this->DisipationFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->DisipationFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ] , u[ center ] ) + - this->TurbulrntEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + ) + + hzInverse * ( + this->DisipationFlux( density_up , density_center, velocity_z_up , velocity_z_center, pressure_up , pressure_center, u[ up ] , u[ center ]) + - this->DisipationFlux( density_center, density_down , velocity_z_center, velocity_z_down , pressure_center, pressure_down , u[ center ], u[ down ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h new file mode 100644 index 000000000..fa7b33b42 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h @@ -0,0 +1,521 @@ +/*************************************************************************** + AUSMPlusEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + AUSMPlusEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "AUSMPlusEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + RealType EnergyFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure, + const RealType& LeftEnergy, + const RealType& RightEnergy ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * ( LeftEnergy + LeftPressure) + MachBorderMinus * ( RightEnergy + RightPressure ) ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->EnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->EnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->EnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->EnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + ) + + hzInverse * ( + this->EnergyFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ], u[ center ] ) + - this->EnergyFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h new file mode 100644 index 000000000..a65ba0174 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h @@ -0,0 +1,205 @@ +/*************************************************************************** + AUSMPlusMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + RealType MainMomentumFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + RealType PressureSplitingPlus = 0; + RealType PressureSplitingMinus = 0; + RealType PressureBorder = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + PressureSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + PressureSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) * (2.0 - LeftMachNumber ) + + 3.0 / 16.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + PressureSplitingPlus = 1.0; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + PressureSplitingMinus = 1.0; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) * (2.0 + RightMachNumber ) + - 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + PressureSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + PressureBorder = PressureSplitingPlus * LeftPressure + PressureSplitingMinus * RightPressure; + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity * LeftVelocity + MachBorderMinus * RightDensity * RightVelocity ) + PressureBorder; + } + + RealType OtherMomentumFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftOtherVelocity, + const RealType& RightOtherVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity * LeftOtherVelocity + MachBorderMinus * RightDensity * RightOtherVelocity ); + } + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType dynamicalViscosity; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h new file mode 100644 index 000000000..1468cf891 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h @@ -0,0 +1,398 @@ +/*************************************************************************** + AUSMPlusMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->OtherMomentumFlux( density_down , density_center, velocity_x_down , velocity_x_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->OtherMomentumFlux( density_center, density_up , velocity_x_center, velocity_x_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h new file mode 100644 index 000000000..d1a8d4304 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumY.h @@ -0,0 +1,371 @@ +/*************************************************************************** + AUSMPlusMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->OtherMomentumFlux( density_down , density_center, velocity_y_down , velocity_y_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->OtherMomentumFlux( density_center, density_up , velocity_y_center, velocity_y_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h new file mode 100644 index 000000000..fcc6183f2 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h @@ -0,0 +1,316 @@ +/*************************************************************************** + AUSMPlusMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_z_west , velocity_z_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_z_center, velocity_z_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_z_south , velocity_z_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->MainMomentumFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->MainMomentumFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h new file mode 100644 index 000000000..66933348b --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h @@ -0,0 +1,459 @@ +/*************************************************************************** + AUSMPlusTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "AUSMPlusTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + }; + + void setBetaStar( const RealType& betaStar ) + { + this->rightHandSide.setBetaStar( betaStar ); + } + + RealType TurbulentEnergyFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure, + const RealType& LeftTurbulentEnergy, + const RealType& RightTurbulentEnergy ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftTurbulentEnergy + MachBorderMinus * RightTurbulentEnergy ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return hxInverse * ( + this->TurbulentEnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return hxInverse * ( + this->TurbulentEnergyFlux( density_west , density_center , velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center , density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return hxInverse * ( + this->TurbulentEnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ] , u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ] , u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + ) + + hzInverse * ( + this->TurbulentEnergyFlux( density_up , density_center, velocity_z_up , velocity_z_center, pressure_up , pressure_center, u[ up ] , u[ center ]) + - this->TurbulentEnergyFlux( density_center, density_down , velocity_z_center, velocity_z_down , pressure_center, pressure_down , u[ center ], u[ down ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h new file mode 100644 index 000000000..582b3ff39 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h @@ -0,0 +1,250 @@ +/*************************************************************************** + LaxFridrichs.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "LaxFridrichsContinuity.h" +#include "LaxFridrichsEnergy.h" +#include "LaxFridrichsMomentumX.h" +#include "LaxFridrichsMomentumY.h" +#include "LaxFridrichsMomentumZ.h" +#include "LaxFridrichsTurbulentEnergy.h" +#include "LaxFridrichsDisipation.h" + +#include "Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = KOmegaOperatorRightHandSide< Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichs +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::DisipationOperatorRightHandSideType DisipationOperatorRightHandSideType; + + typedef LaxFridrichsContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef LaxFridrichsMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef LaxFridrichsMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef LaxFridrichsMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef LaxFridrichsEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef LaxFridrichsTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + typedef LaxFridrichsDisipation< Mesh, DisipationOperatorRightHandSideType, Real, Index > DisipationOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + typedef Pointers::SharedPointer< DisipationOperatorType > DisipationOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + LaxFridrichs() + : artificialViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "Lax-Friedrichs" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->disipationOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); + this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->turbulentEnergyOperatorPointer->setArtificialViscosity( artificialViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + this->disipationOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + this->disipationOperatorPointer->setVelocity( velocity ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->disipationOperatorPointer->setDensity( density ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->disipationOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setCharacteristicLength( RealType& characteristicLength ) + { + this->turbulentEnergyOperatorPointer->setCharacteristicLength( characteristicLength ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->disipationOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->disipationOperatorPointer->setSigmaEpsilon( sigmaEpsilon ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->disipationOperatorPointer->setDisipation( disipation ); + this->turbulentEnergyOperatorPointer->setDisipation( disipation ); + } + + void setBeta( const RealType& beta ) + { + this->disipationOperatorPointer->setBeta( beta ); + } + + void setAlpha( const RealType& alpha ) + { + this->disipationOperatorPointer->setAlpha( alpha ); + } + + void setBetaStar( const RealType& betaStar ) + { + this->turbulentEnergyOperatorPointer->setBetaStar( betaStar ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + const DisipationOperatorPointer& getDisipationOperator() const + { + return this->disipationOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + DisipationOperatorPointer disipationOperatorPointer; + + RealType artificialViscosity; + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h new file mode 100644 index 000000000..e82c9d424 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsContinuity.h @@ -0,0 +1,310 @@ +/*************************************************************************** + LaxFridrichsContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsContinuityBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + RealType artificialViscosity; +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + +// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) +// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsDisipation.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsDisipation.h new file mode 100644 index 000000000..76b41623f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsDisipation.h @@ -0,0 +1,352 @@ +/*************************************************************************** + LaxFridrichsDisipation.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsDisipationBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsDisipationBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsDisipation< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity( velocity ); + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->rightHandSide.setDensity( density ); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity( turbulentViscosity ); + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity( dynamicalViscosity ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->rightHandSide.setSigmaEpsilon( sigmaEpsilon ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy( turbulentEnergy ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + } + + void setBeta( const RealType& beta ) + { + this->rightHandSide.setBeta( beta ); + } + + void setAlpha( const RealType& alpha ) + { + this->rightHandSide.setAlpha( alpha ); + } + + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + RealType artificialViscosity; +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsDisipation +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsDisipation< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsDisipationBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + +// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) +// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsDisipation< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsDisipationBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsDisipation< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsDisipationBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h new file mode 100644 index 000000000..16256aa80 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -0,0 +1,349 @@ +/*************************************************************************** + LaxFridrichsEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) + - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east + - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ) + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse + + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) + -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ) + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h new file mode 100644 index 000000000..cde9e58c8 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -0,0 +1,88 @@ +/*************************************************************************** + LaxFridrichsMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsMomentumBase() + : artificialViscosity( 1.0 ){}; + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + } + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h new file mode 100644 index 000000000..57258d1a5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumX.h @@ -0,0 +1,295 @@ +/*************************************************************************** + LaxFridrichsMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) + - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ) + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_u[ up ] * velocity_z_up ) + - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ) + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h new file mode 100644 index 000000000..4cca02779 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumY.h @@ -0,0 +1,280 @@ +/*************************************************************************** + LaxFridrichsMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ) + + + this->rightHandSide(rho_v, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse + + ( ( rho_v[ up ] * velocity_z_up ) + - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ) + + + this->rightHandSide(rho_v, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h new file mode 100644 index 000000000..1f394bfef --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumZ.h @@ -0,0 +1,251 @@ +/*************************************************************************** + LaxFridrichsMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) + -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) + - ( rho_w[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_w[ north ] * velocity_y_north ) + - ( rho_w[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) + - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ) + + + this->rightHandSide(rho_w, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h new file mode 100644 index 000000000..5d1232d41 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h @@ -0,0 +1,342 @@ +/*************************************************************************** + LaxFridrichsTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsTurbulentEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + }; + + void setBetaStar( const RealType& betaStar ) + { + this->rightHandSide.setBetaStar( betaStar ); + } + + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + RealType artificialViscosity; +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + +// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) +// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h new file mode 100644 index 000000000..68b71b85e --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h @@ -0,0 +1,253 @@ +/*************************************************************************** + StegerWarming.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "StegerWarmingContinuity.h" +#include "StegerWarmingEnergy.h" +#include "StegerWarmingMomentumX.h" +#include "StegerWarmingMomentumY.h" +#include "StegerWarmingMomentumZ.h" +#include "StegerWarmingTurbulentEnergy.h" +#include "StegerWarmingDisipation.h" + +#include "Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = KOmegaOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarming +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::DisipationOperatorRightHandSideType DisipationOperatorRightHandSideType; + + + typedef StegerWarmingContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef StegerWarmingMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef StegerWarmingMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef StegerWarmingMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef StegerWarmingEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef StegerWarmingTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + typedef StegerWarmingDisipation< Mesh, DisipationOperatorRightHandSideType, Real, Index > DisipationOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + typedef Pointers::SharedPointer< DisipationOperatorType > DisipationOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + StegerWarming() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "Steger-Warming"<< std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->disipationOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + this->disipationOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + this->turbulentEnergyOperatorPointer->setGamma( gamma ); + this->disipationOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + this->turbulentEnergyOperatorPointer->setPressure( pressure ); + this->disipationOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + this->turbulentEnergyOperatorPointer->setDensity( density ); + this->disipationOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + this->disipationOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->disipationOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->disipationOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->disipationOperatorPointer->setSigmaEpsilon( sigmaEpsilon ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->disipationOperatorPointer->setDisipation( disipation ); + this->turbulentEnergyOperatorPointer->setDisipation( disipation ); + } + + void setBeta( const RealType& beta ) + { + this->disipationOperatorPointer->setBeta( beta ); + } + + void setAlpha( const RealType& alpha ) + { + this->disipationOperatorPointer->setAlpha( alpha ); + } + + void setBetaStar( const RealType& betaStar ) + { + this->turbulentEnergyOperatorPointer->setBetaStar( betaStar ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + const DisipationOperatorPointer& getDisipationOperator() const + { + return this->disipationOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + DisipationOperatorPointer disipationOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h new file mode 100644 index 000000000..5fbef7be6 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingContinuity.h @@ -0,0 +1,396 @@ +/*************************************************************************** + StegerWarmingContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingDisipation.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingDisipation.h new file mode 100644 index 000000000..a91a8b48b --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingDisipation.h @@ -0,0 +1,458 @@ +/*************************************************************************** + StegerWarmingDisipation.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingDisipationBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingDisipation< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity( velocity ); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + this->rightHandSide.setDensity( density ); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity( turbulentViscosity ); + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity( dynamicalViscosity ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->rightHandSide.setSigmaEpsilon( sigmaEpsilon ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy( turbulentEnergy ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + } + + void setBeta( const RealType& beta ) + { + this->rightHandSide.setBeta( beta ); + } + + void setAlpha( const RealType& alpha ) + { + this->rightHandSide.setAlpha( alpha ); + } + + RealType positiveDisipationFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& disipation ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return disipation * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); + else if ( machNumber <= 1.0 ) + return disipation * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); + else + return disipation * velocity; + }; + + RealType negativeDisipationFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& disipation ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return disipation * velocity; + else if ( machNumber <= 0.0 ) + return disipation * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); + else if ( machNumber <= 1.0 ) + return disipation * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingDisipation +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingDisipation< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingDisipationBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingDisipation< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingDisipationBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingDisipation< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingDisipationBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + -hzInverse * ( + this->positiveDisipationFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_down , velocity_z_down , pressure_down , u[ down ] ) + - this->negativeDisipationFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_up , velocity_z_up , pressure_up , u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h new file mode 100644 index 000000000..f51bf7e53 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h @@ -0,0 +1,560 @@ +/*************************************************************************** + StegerWarmingEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hzInverse * ( + this->positiveEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_z_down , velocity_x_down , velocity_y_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_z_up , velocity_x_up , velocity_y_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h new file mode 100644 index 000000000..e6c6c1fbb --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h @@ -0,0 +1,150 @@ +/*************************************************************************** + StegerWarmingMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + } + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber + 1.0 ) * ( machNumber + 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber + 1.0 ) * (machNumber + 1.0 ) ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber - 1.0 ) * (machNumber - 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber - 1.0 ) * ( machNumber - 1.0 ) ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h new file mode 100644 index 000000000..c6588083c --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumX.h @@ -0,0 +1,356 @@ +/*************************************************************************** + StegerWarmingMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h new file mode 100644 index 000000000..210fb6087 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumY.h @@ -0,0 +1,326 @@ +/*************************************************************************** + StegerWarmingMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h new file mode 100644 index 000000000..135352d2f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumZ.h @@ -0,0 +1,282 @@ +/*************************************************************************** + StegerWarmingMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 0-hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h new file mode 100644 index 000000000..e4d365510 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h @@ -0,0 +1,452 @@ +/*************************************************************************** + StegerWarmingTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + }; + + void setBetaStar( const RealType& betaStar ) + { + this->rightHandSide.setBetaStar( betaStar ); + } + + RealType positiveTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); + else if ( machNumber <= 1.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); + else + return turbulentEnergy * velocity; + }; + + RealType negativeTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return turbulentEnergy * velocity; + else if ( machNumber <= 0.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); + else if ( machNumber <= 1.0 ) + return turbulentEnergy * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + -hzInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_down , velocity_z_down , pressure_down , u[ down ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_up , velocity_z_up , pressure_up , u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h new file mode 100644 index 000000000..96536383e --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h @@ -0,0 +1,252 @@ +/*************************************************************************** + VanLeer.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "VanLeerContinuity.h" +#include "VanLeerEnergy.h" +#include "VanLeerMomentumX.h" +#include "VanLeerMomentumY.h" +#include "VanLeerMomentumZ.h" +#include "VanLeerTurbulentEnergy.h" +#include "VanLeerDisipation.h" + +#include "Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = KOmegaOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeer +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::TurbulentEnergyOperatorRightHandSideType TurbulentEnergyOperatorRightHandSideType; + typedef typename OperatorRightHandSide::DisipationOperatorRightHandSideType DisipationOperatorRightHandSideType; + + typedef VanLeerContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef VanLeerMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef VanLeerMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef VanLeerMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef VanLeerEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + typedef VanLeerTurbulentEnergy< Mesh, TurbulentEnergyOperatorRightHandSideType, Real, Index > TurbulentEnergyOperatorType; + typedef VanLeerDisipation< Mesh, DisipationOperatorRightHandSideType, Real, Index > DisipationOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorType > TurbulentEnergyOperatorPointer; + typedef Pointers::SharedPointer< DisipationOperatorType > DisipationOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + VanLeer() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "VanLeer" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->disipationOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + this->turbulentEnergyOperatorPointer->setTau( tau ); + this->disipationOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + this->turbulentEnergyOperatorPointer->setGamma( gamma ); + this->disipationOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + this->turbulentEnergyOperatorPointer->setPressure( pressure ); + this->disipationOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + this->turbulentEnergyOperatorPointer->setDensity( density ); + this->disipationOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + this->turbulentEnergyOperatorPointer->setVelocity( velocity ); + this->disipationOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->disipationOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setSigmaK( RealType& sigmaK ) + { + this->turbulentEnergyOperatorPointer->setSigmaK( sigmaK ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->disipationOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->disipationOperatorPointer->setSigmaEpsilon( sigmaEpsilon ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->disipationOperatorPointer->setDisipation( disipation ); + this->turbulentEnergyOperatorPointer->setDisipation( disipation ); + } + + void setBeta( const RealType& beta ) + { + this->disipationOperatorPointer->setBeta( beta ); + } + + void setAlpha( const RealType& alpha ) + { + this->disipationOperatorPointer->setAlpha( alpha ); + } + + void setBetaStar( const RealType& betaStar ) + { + this->turbulentEnergyOperatorPointer->setBetaStar( betaStar ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const TurbulentEnergyOperatorPointer& getTurbulentEnergyOperator() const + { + return this->turbulentEnergyOperatorPointer; + } + + const DisipationOperatorPointer& getDisipationOperator() const + { + return this->disipationOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + TurbulentEnergyOperatorPointer turbulentEnergyOperatorPointer; + DisipationOperatorPointer disipationOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerContinuity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerContinuity.h new file mode 100644 index 000000000..3b497125a --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerContinuity.h @@ -0,0 +1,396 @@ +/*************************************************************************** + VanLeerContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "VanLeerContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + RealType multiply (const RealType& a, const RealType& b ) const + { + return a * b; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerDisipation.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerDisipation.h new file mode 100644 index 000000000..e4998ea2d --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerDisipation.h @@ -0,0 +1,453 @@ +/*************************************************************************** + VanLeerDisipation.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerDisipationBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "VanLeerDisipation< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity( velocity ); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + this->rightHandSide.setDensity( density ); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity( turbulentViscosity ); + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity( dynamicalViscosity ); + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->rightHandSide.setSigmaEpsilon( sigmaEpsilon ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy( turbulentEnergy ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + } + + void setBeta( const RealType& beta ) + { + this->rightHandSide.setBeta( beta ); + } + + void setAlpha( const RealType& alpha ) + { + this->rightHandSide.setAlpha( alpha ); + } + + RealType positiveDisipationFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& disipation ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return disipation * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); + else + return disipation * velocity; + }; + + RealType negativeDisipationFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& disipation ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return disipation * velocity; + else if ( machNumber <= 1.0 ) + return - disipation * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerDisipation +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerDisipation< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerDisipationBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerDisipation< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerDisipationBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerDisipation< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerDisipationBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerDisipationBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeDisipationFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeDisipationFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + -hzInverse * ( + this->positiveDisipationFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + - this->positiveDisipationFlux( density_down , velocity_z_down , pressure_down , u[ down ] ) + - this->negativeDisipationFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + + this->negativeDisipationFlux( density_up , velocity_z_up , pressure_up , u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h new file mode 100644 index 000000000..3e372e54a --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h @@ -0,0 +1,592 @@ +/*************************************************************************** + VanLeerEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + VanLeerEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "VanLeerEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hzInverse * ( + this->positiveEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_z_down , velocity_x_down , velocity_y_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_z_up , velocity_x_up , velocity_y_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h new file mode 100644 index 000000000..d8e80c103 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h @@ -0,0 +1,145 @@ +/*************************************************************************** + VanLeerMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * ( - 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType dynamicalViscosity; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h new file mode 100644 index 000000000..04e41c015 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumX.h @@ -0,0 +1,410 @@ +/*************************************************************************** + VanLeerMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h new file mode 100644 index 000000000..65ac84828 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumY.h @@ -0,0 +1,381 @@ +/*************************************************************************** + VanLeerMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h new file mode 100644 index 000000000..125166cb8 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumZ.h @@ -0,0 +1,322 @@ +/*************************************************************************** + VanLeerMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h new file mode 100644 index 000000000..aa4c46976 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h @@ -0,0 +1,447 @@ +/*************************************************************************** + VanLeerTurbulentEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerTurbulentEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "VanLeerTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->rightHandSide.setTurbulentEnergy(turbulentEnergy); + }; + + void setSigmaK( RealType& sigmaK ) + { + this->rightHandSide.setSigmaK( sigmaK ); + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->rightHandSide.setDisipation( disipation ); + }; + + void setBetaStar( const RealType& betaStar ) + { + this->rightHandSide.setBetaStar( betaStar ); + } + + RealType positiveTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return turbulentEnergy * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); + else + return turbulentEnergy * velocity; + }; + + RealType negativeTurbulentEnergyFlux( const RealType& density, const RealType& velocity, const RealType& pressure, const RealType& turbulentEnergy ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return turbulentEnergy * velocity; + else if ( machNumber <= 1.0 ) + return - turbulentEnergy * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerTurbulentEnergy +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerTurbulentEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerTurbulentEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerTurbulentEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerTurbulentEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerTurbulentEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_west , velocity_x_west , pressure_west , u[ west ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_x_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_east , velocity_x_east , pressure_east , u[ east ] ) + ) + -hyInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_south , velocity_y_south , pressure_south , u[ south ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_y_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_north , velocity_y_north , pressure_north , u[ north ] ) + ) + -hzInverse * ( + this->positiveTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + - this->positiveTurbulentEnergyFlux( density_down , velocity_z_down , pressure_down , u[ down ] ) + - this->negativeTurbulentEnergyFlux( density_center, velocity_z_center, pressure_center, u[ center ] ) + + this->negativeTurbulentEnergyFlux( density_up , velocity_z_up , pressure_up , u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaContinuityOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaContinuityOperatorRightHandSide.h new file mode 100644 index 000000000..f5c9883ff --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaContinuityOperatorRightHandSide.h @@ -0,0 +1,218 @@ +/*************************************************************************** + KOmegaContinuityOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaContinuityRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + protected: + +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaContinuityRightHandSide +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaContinuityRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaContinuityRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaContinuityRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaContinuityRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaContinuityRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaContinuityRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + + return 0; + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaDisipationOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaDisipationOperatorRightHandSide.h new file mode 100644 index 000000000..ffd928cca --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaDisipationOperatorRightHandSide.h @@ -0,0 +1,592 @@ +/*************************************************************************** + KOmegaDisipationOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaDisipationRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + void setBeta( const RealType& beta ) + { + this->beta = beta; + } + + void setAlpha( const RealType& alpha ) + { + this->alpha = alpha; + } + + void setSigmaEpsilon( const RealType& sigmaEpsilon ) + { + this->sigmaEpsilon = sigmaEpsilon; + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->disipation = disipation; + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + MeshFunctionPointer turbulentEnergy; + + MeshFunctionPointer disipation; + + MeshFunctionPointer density; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; + + RealType alpha; + + RealType beta; + + RealType sigmaEpsilon; +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaDisipationRightHandSide +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaDisipationRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaDisipationRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaDisipationRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& disipation_center = this->disipation.template getData< DeviceType >()[ center ]; + const RealType& disipation_east = this->disipation.template getData< DeviceType >()[ east ]; + const RealType& disipation_west = this->disipation.template getData< DeviceType >()[ west ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return + this->alpha * disipation_center / turbulentEnergy_center + * 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - + this->beta * disipation_center * disipation_center + + + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_west + - disipation_center * turbulentViscosity_center + disipation_west * turbulentViscosity_west + ) * hxSquareInverse * this->sigmaEpsilon; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaDisipationRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaDisipationRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaDisipationRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& disipation_center = this->disipation.template getData< DeviceType >()[ center ]; + const RealType& disipation_west = this->disipation.template getData< DeviceType >()[ west ]; + const RealType& disipation_east = this->disipation.template getData< DeviceType >()[ east ]; + const RealType& disipation_north = this->disipation.template getData< DeviceType >()[ north ]; + const RealType& disipation_south = this->disipation.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return this->alpha * disipation_center / turbulentEnergy_center + * ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + + ( ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + ) + - + this->beta * disipation_center * disipation_center + + + this->dynamicalViscosity + * ( disipation_north - 2 * disipation_center + disipation_south ) + * hySquareInverse + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_south + - disipation_center * turbulentViscosity_center + disipation_south * turbulentViscosity_south + ) * hySquareInverse * this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_west + - disipation_center * turbulentViscosity_center + disipation_west * turbulentViscosity_west + ) * hxSquareInverse * this->sigmaEpsilon; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaDisipationRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaDisipationRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaDisipationRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + const RealType& turbulentEnergy_up = this->turbulentEnergy.template getData< DeviceType >()[ up ]; + const RealType& turbulentEnergy_down = this->turbulentEnergy.template getData< DeviceType >()[ down ]; + + const RealType& disipation_center = this->disipation.template getData< DeviceType >()[ center ]; + const RealType& disipation_west = this->disipation.template getData< DeviceType >()[ west ]; + const RealType& disipation_east = this->disipation.template getData< DeviceType >()[ east ]; + const RealType& disipation_north = this->disipation.template getData< DeviceType >()[ north ]; + const RealType& disipation_south = this->disipation.template getData< DeviceType >()[ south ]; + const RealType& disipation_up = this->disipation.template getData< DeviceType >()[ up ]; + const RealType& disipation_down = this->disipation.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return this->alpha * disipation_center / turbulentEnergy_center +// 3D uT_11_x + * ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_x_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 +// vT_12_x + + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_east - velocity_y_west ) * hxInverse / 2 +// wT_13_x + + ( ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_z_east - velocity_z_west ) * hxInverse / 2 +// uT_21_y + + ( ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_north - velocity_x_south ) * hyInverse / 2 +// 3D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 +// wT_23_y + + ( ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + + ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_z_north - velocity_z_south ) * hyInverse / 2 +// uT_31_z + + ( ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_up - velocity_x_down ) * hzInverse / 2 +// T_32_z + + ( ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + + ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_up - velocity_y_down ) * hzInverse / 2 +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) + - + this->beta * disipation_center * disipation_center + + + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * disipation_west + - disipation_center * turbulentViscosity_center + disipation_west * disipation_west + ) * hxSquareInverse * this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_north - 2 * disipation_center + disipation_south ) + * hySquareInverse + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_south + - disipation_center * turbulentViscosity_center + disipation_south * turbulentViscosity_south + ) * hySquareInverse * this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_up - 2 * disipation_center + disipation_down ) + * hySquareInverse + + ( disipation_up * turbulentViscosity_up - disipation_center * turbulentViscosity_down + - disipation_center * turbulentViscosity_center + disipation_down * turbulentViscosity_down + ) * hySquareInverse * this->sigmaEpsilon; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaEnergyOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaEnergyOperatorRightHandSide.h new file mode 100644 index 000000000..27d051ce2 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaEnergyOperatorRightHandSide.h @@ -0,0 +1,687 @@ +/*************************************************************************** + KOmegaEnergyOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaEnergyRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + KOmegaEnergyRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + MeshFunctionPointer turbulentEnergy; + + MeshFunctionPointer density; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaEnergyRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaEnergyRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return +// 1D uT_11_x + 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity +// 1D_t_11_x + + + 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse + + + 2.0 / 3.0 * ( velocity_x_east * density_east * turbulentEnergy_east + - velocity_x_west * density_west * turbulentEnergy_west + ) * hxInverse / 2; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaEnergyRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return +// 2D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// vT_12_x + + ( ( velocity_x_northEast * velocity_y_east - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_west + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center - velocity_y_center * velocity_y_west + - velocity_y_center * velocity_y_center + velocity_y_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_21_y + + ( ( velocity_y_northEast * velocity_x_north - velocity_y_southEast * velocity_x_south + - velocity_y_northWest * velocity_x_north + velocity_y_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center - velocity_x_center * velocity_x_south + - velocity_x_center * velocity_x_center + velocity_x_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 2D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// ut_11_x + + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east * turbulentViscosity_east - velocity_y_southEast * velocity_x_east * turbulentViscosity_east + - velocity_y_northWest * velocity_x_west * turbulentViscosity_west + velocity_y_southWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( velocity_x_east * density_east * turbulentEnergy_east + - velocity_x_west * density_west * turbulentEnergy_west + ) * hxInverse / 2 + ) +// vt_12_x + + ( ( velocity_x_northEast * velocity_y_east * turbulentViscosity_east - velocity_x_southEast * velocity_y_east * turbulentViscosity_east + - velocity_x_northWest * velocity_y_west * turbulentViscosity_west + velocity_x_southWest * velocity_y_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_west * turbulentViscosity_west + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_west * velocity_y_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// ut_21_y + + ( ( velocity_y_northEast * velocity_x_north * turbulentViscosity_north - velocity_y_southEast * velocity_x_south * turbulentViscosity_south + - velocity_y_northWest * velocity_x_north * turbulentViscosity_north + velocity_y_southWest * velocity_x_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_south * turbulentViscosity_south + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_south * velocity_x_south * turbulentViscosity_south + ) * hySquareInverse + ) +// vt_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_south * turbulentViscosity_south + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_south * velocity_y_south * turbulentViscosity_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north * turbulentViscosity_north - velocity_x_southEast * velocity_y_south * turbulentViscosity_south + - velocity_x_northWest * velocity_y_north * turbulentViscosity_north + velocity_x_southWest * velocity_y_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( velocity_y_north * density_north * turbulentEnergy_north + - velocity_y_south * density_south * turbulentEnergy_south + ) * hyInverse / 2 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaEnergyRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + const RealType& turbulentEnergy_up = this->turbulentEnergy.template getData< DeviceType >()[ up ]; + const RealType& turbulentEnergy_down = this->turbulentEnergy.template getData< DeviceType >()[ down ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east + - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// vT_12_x + + ( ( velocity_x_northEast * velocity_y_east - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_west + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center - velocity_y_center * velocity_y_west + - velocity_y_center * velocity_y_center + velocity_y_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// wT_13_x + + ( ( velocity_x_upEast * velocity_z_east - velocity_x_downEast * velocity_z_east + - velocity_x_upWest * velocity_z_west + velocity_x_downWest * velocity_z_west + ) * hxInverse * hzInverse / 4 + + ( velocity_z_east * velocity_z_center - velocity_z_center * velocity_z_west + - velocity_z_center * velocity_z_center + velocity_z_west * velocity_z_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_21_y + + ( ( velocity_y_northEast * velocity_x_north - velocity_y_southEast * velocity_x_south + - velocity_y_northWest * velocity_x_north + velocity_y_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center - velocity_x_center * velocity_x_south + + velocity_x_center * velocity_x_center + velocity_x_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// wT_23_y + + ( ( velocity_y_upNorth * velocity_z_north - velocity_y_downNorth * velocity_y_north + - velocity_y_upSouth * velocity_z_south + velocity_y_downSouth * velocity_z_south + ) * hyInverse * hzInverse / 4 + + ( velocity_z_north * velocity_z_center - velocity_z_center * velocity_z_south + - velocity_z_center * velocity_z_center + velocity_z_south * velocity_z_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// uT_31_z + + ( ( velocity_x_up * velocity_x_center - velocity_x_center * velocity_x_center + - velocity_x_center * velocity_x_down + velocity_x_down * velocity_x_down + ) * hzSquareInverse + + ( velocity_z_upEast * velocity_x_up - velocity_z_downEast * velocity_x_down + - velocity_z_upWest * velocity_x_up + velocity_z_downWest * velocity_x_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_z + + ( ( velocity_z_upNorth * velocity_y_up - velocity_z_downNorth * velocity_y_down + - velocity_z_upSouth * velocity_y_up + velocity_z_downSouth * velocity_y_down + ) * hyInverse * hzInverse / 4 + + ( velocity_x_up * velocity_y_center - velocity_x_center * velocity_y_down + - velocity_x_center * velocity_y_center + velocity_x_down * velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down + - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down + - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down + - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// ut_11_x + + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east * turbulentViscosity_east - velocity_y_southEast * velocity_x_east * turbulentViscosity_east + - velocity_y_northWest * velocity_x_west * turbulentViscosity_west + velocity_y_southWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east * turbulentViscosity_east - velocity_z_downEast * velocity_x_east * turbulentViscosity_east + - velocity_z_upWest * velocity_x_west * turbulentViscosity_west + velocity_z_downWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( velocity_y_north * density_north * turbulentEnergy_north + - velocity_y_south * density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// vt_12_x + + ( ( velocity_x_northEast * velocity_y_east * turbulentViscosity_east - velocity_x_southEast * velocity_y_east * turbulentViscosity_east + - velocity_x_northWest * velocity_y_west * turbulentViscosity_west + velocity_x_southWest * velocity_y_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_west * turbulentViscosity_west + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_west * velocity_y_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// wt_13_x + + ( ( velocity_x_upEast * velocity_z_east * turbulentViscosity_east - velocity_x_downEast * velocity_z_east * turbulentViscosity_east + - velocity_x_upWest * velocity_z_west * turbulentViscosity_west + velocity_x_downWest * velocity_z_west * turbulentViscosity_west + ) * hxInverse * hzInverse / 4 + + ( velocity_z_east * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_west * turbulentViscosity_west + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_west * velocity_z_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// ut_21_y + + ( ( velocity_y_northEast * velocity_x_north * turbulentViscosity_north - velocity_y_southEast * velocity_x_south * turbulentViscosity_south + - velocity_y_northWest * velocity_x_north * turbulentViscosity_north + velocity_y_southWest * velocity_x_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_south * turbulentViscosity_south + + velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_south * velocity_x_south * turbulentViscosity_south + ) * hySquareInverse + ) +// vt_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_south * turbulentViscosity_south + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_south * velocity_y_south * turbulentViscosity_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north * turbulentViscosity_north - velocity_x_southEast * velocity_y_south * turbulentViscosity_south + - velocity_x_northWest * velocity_y_north * turbulentViscosity_north + velocity_x_southWest * velocity_y_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north * turbulentViscosity_north - velocity_z_downNorth * velocity_y_north * turbulentViscosity_north + - velocity_z_upSouth * velocity_y_south * turbulentViscosity_south + velocity_z_downSouth * velocity_y_south * turbulentViscosity_south + ) * hyInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( velocity_y_north * density_north * turbulentEnergy_north + - velocity_y_south * density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// wt_23_y + + ( ( velocity_y_upNorth * velocity_z_north * turbulentViscosity_north - velocity_y_downNorth * velocity_y_north * turbulentViscosity_north + - velocity_y_upSouth * velocity_z_south * turbulentViscosity_south + velocity_y_downSouth * velocity_z_south * turbulentViscosity_south + ) * hyInverse * hzInverse / 4 + + ( velocity_z_north * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_south * turbulentViscosity_south + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_south * velocity_z_south * turbulentViscosity_south + ) * hySquareInverse + ) +// ut_31_z + + ( ( velocity_x_up * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_center * turbulentViscosity_center + - velocity_x_center * velocity_x_down * turbulentViscosity_down + velocity_x_down * velocity_x_down * turbulentViscosity_down + ) * hzSquareInverse + + ( velocity_z_upEast * velocity_x_up * turbulentViscosity_up - velocity_z_downEast * velocity_x_down * turbulentViscosity_down + - velocity_z_upWest * velocity_x_up * turbulentViscosity_up + velocity_z_downWest * velocity_x_down * turbulentViscosity_down + ) * hxInverse * hzInverse / 4 + ) +// vt_32_z + + ( ( velocity_z_upNorth * velocity_y_up * turbulentViscosity_up - velocity_z_downNorth * velocity_y_down * turbulentViscosity_down + - velocity_z_upSouth * velocity_y_up * turbulentViscosity_up + velocity_z_downSouth * velocity_y_down * turbulentViscosity_down + ) * hyInverse * hzInverse / 4 + + ( velocity_x_up * velocity_y_center * turbulentViscosity_center - velocity_x_center * velocity_y_down * turbulentViscosity_down + - velocity_x_center * velocity_y_center * turbulentViscosity_center + velocity_x_down * velocity_y_down * turbulentViscosity_down + ) * hzSquareInverse + ) +// wt_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_down * turbulentViscosity_down + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_down * velocity_z_down * turbulentViscosity_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up * turbulentViscosity_up - velocity_y_downNorth * velocity_z_down * turbulentViscosity_down + - velocity_y_upSouth * velocity_z_up * turbulentViscosity_up + velocity_y_downSouth * velocity_z_down * turbulentViscosity_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up * turbulentViscosity_up - velocity_x_downEast * velocity_z_down * turbulentViscosity_down + - velocity_x_upWest * velocity_z_up * turbulentViscosity_up + velocity_x_downWest * velocity_z_down * turbulentViscosity_down + ) * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( velocity_z_up * density_up * turbulentEnergy_up + - velocity_z_down * density_down * turbulentEnergy_down + ) * hzInverse / 2 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumBaseOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumBaseOperatorRightHandSide.h new file mode 100644 index 000000000..4fa422ca8 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumBaseOperatorRightHandSide.h @@ -0,0 +1,75 @@ +/*************************************************************************** + KOmegaMomentumRightHandSideBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaMomentumRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + KOmegaMomentumRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + MeshFunctionPointer turbulentEnergy; + + MeshFunctionPointer density; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumXOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumXOperatorRightHandSide.h new file mode 100644 index 000000000..fc61a5142 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumXOperatorRightHandSide.h @@ -0,0 +1,450 @@ +/*************************************************************************** + KOmegaMomentumXRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "KOmegaMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaMomentumXRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaMomentumXRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return +// 1D T_11_x + 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity +// 1D t_11_x + + + 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse + + + 2.0 / 3.0 * ( density_east * turbulentEnergy_east + - density_west * turbulentEnergy_west + ) * hxInverse / 2; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return +// 2D T_11_x + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// t_11_x + + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( density_east * turbulentEnergy_east + - density_west * turbulentEnergy_west + ) * hxInverse / 2 + ) +// t_21_y + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + ) * hySquareInverse + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D T_11_x + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hxSquareInverse + ) * this->dynamicalViscosity +// T_31_z + + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + + ( velocity_x_up - 2 * velocity_x_center + velocity_x_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +//t_11_x + + + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest + velocity_z_downWest ) + ) * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( density_east * turbulentEnergy_east + - density_west * turbulentEnergy_west + ) * hxInverse / 2 + ) +// t_21_y + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north - turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + ) * hySquareInverse + ) +// t_31_z + + ( ( turbulentViscosity_up * ( velocity_z_upEast - velocity_z_upWest ) - turbulentViscosity_down * ( velocity_z_downEast - velocity_z_downWest ) + ) * hxInverse * hzInverse / 4 + + ( turbulentViscosity_up * velocity_x_up - ( turbulentViscosity_up + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_down + ) * hzSquareInverse + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumYOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumYOperatorRightHandSide.h new file mode 100644 index 000000000..e246ec6fd --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumYOperatorRightHandSide.h @@ -0,0 +1,417 @@ +/*************************************************************************** + KOmegaMomentumYRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "KOmegaMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaMomentumYRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaMomentumYRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaMomentumYRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + + return +// 2D T_22_y + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_12_x + + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east + ) * hxSquareInverse + ) * this->dynamicalViscosity + + +// t_22_y + ( 4.0 / 3.0 * ( turbulentViscosity_north * velocity_y_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_x_northEast - velocity_x_northWest ) - turbulentViscosity_south * ( velocity_x_southEast - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + + + 2.0 / 3.0 * ( density_north * turbulentEnergy_north + - density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// t_12_x + + ( ( turbulentViscosity_east * (velocity_x_northEast - velocity_x_southEast ) - turbulentViscosity_west * (velocity_x_northWest - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_east * velocity_y_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_west + ) * hxSquareInverse + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaMomentumYRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// T_12_y + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east - 2 * velocity_y_center + velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// 3D T_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_y + + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + + ( velocity_y_up - 2 * velocity_y_center + velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity + + +// t_12_x + ( ( turbulentViscosity_east * ( velocity_x_northEast - velocity_x_southEast ) - turbulentViscosity_west * ( velocity_x_northWest - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_east * velocity_y_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_west + ) * hxSquareInverse + ) +// t_22_y + + ( 4.0 / 3.0 * ( turbulentViscosity_north * velocity_y_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_x_northEast - velocity_x_northWest ) - turbulentViscosity_south * ( velocity_x_southEast - velocity_x_southWest) + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_z_upNorth - velocity_z_downNorth ) - turbulentViscosity_south * ( velocity_z_upSouth - velocity_z_downSouth ) + ) * hyInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( density_north * turbulentEnergy_north + - density_south * turbulentEnergy_south + ) * hyInverse / 2 + ) +// t_32_z + + ( ( turbulentViscosity_up * ( velocity_z_upNorth - velocity_z_upSouth ) - turbulentViscosity_down * ( velocity_z_downNorth - velocity_z_downSouth ) + ) * hyInverse * hzInverse / 4 + + ( turbulentViscosity_up * velocity_y_up - ( turbulentViscosity_up + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_down + ) * hzSquareInverse + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumZOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumZOperatorRightHandSide.h new file mode 100644 index 000000000..6b92ad3c5 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumZOperatorRightHandSide.h @@ -0,0 +1,343 @@ +/*************************************************************************** + KOmegaMomentumZRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "KOmegaMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaMomentumZRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaMomentumZRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaMomentumZRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_up = this->turbulentEnergy.template getData< DeviceType >()[ up ]; + const RealType& turbulentEnergy_down = this->turbulentEnergy.template getData< DeviceType >()[ down ]; + + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// T_13_x + ( ( velocity_z_east - 2 * velocity_z_center + velocity_z_west ) + * hxSquareInverse + + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// T_23_y + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + * hySquareInverse + ) + * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// t_13_x + + ( ( turbulentViscosity_east * velocity_z_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_west ) + * hxSquareInverse + + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest + velocity_x_downWest ) ) + * hxInverse * hzInverse / 4 + ) +// t_23_y + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + * hySquareInverse + ) +// t_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + + + 2.0 / 3.0 * ( density_up * turbulentEnergy_up + - density_down * turbulentEnergy_down + ) * hzInverse / 2 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h new file mode 100644 index 000000000..58daab984 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h @@ -0,0 +1,169 @@ +/*************************************************************************** + KOmegaOpratorRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "KOmegaContinuityOperatorRightHandSide.h" +#include "KOmegaEnergyOperatorRightHandSide.h" +#include "KOmegaMomentumXOperatorRightHandSide.h" +#include "KOmegaMomentumYOperatorRightHandSide.h" +#include "KOmegaMomentumZOperatorRightHandSide.h" +#include "KOmegaTurbulentEnergyOperatorRightHandSide.h" +#include "KOmegaDisipationOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaOperatorRightHandSide +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef KOmegaContinuityRightHandSide< Mesh, Real, Index > ContinuityOperatorRightHandSideType; + typedef KOmegaMomentumXRightHandSide< Mesh, Real, Index > MomentumXOperatorRightHandSideType; + typedef KOmegaMomentumYRightHandSide< Mesh, Real, Index > MomentumYOperatorRightHandSideType; + typedef KOmegaMomentumZRightHandSide< Mesh, Real, Index > MomentumZOperatorRightHandSideType; + typedef KOmegaEnergyRightHandSide< Mesh, Real, Index > EnergyOperatorRightHandSideType; + typedef KOmegaTurbulentEnergyRightHandSide< Mesh, Real, Index > TurbulentEnergyOperatorRightHandSideType; + typedef KOmegaDisipationRightHandSide< Mesh, Real, Index > DisipationOperatorRightHandSideType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorRightHandSideType > ContinuityOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumXOperatorRightHandSideType > MomentumXOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumYOperatorRightHandSideType > MomentumYOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumZOperatorRightHandSideType > MomentumZOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< EnergyOperatorRightHandSideType > EnergyOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< TurbulentEnergyOperatorRightHandSideType > TurbulentEnergyOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< DisipationOperatorRightHandSideType > DisipationOperatorRightHandSidePointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + KOmegaOperatorRightHandSide() + : dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->turbulentEnergyOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + return true; + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumXOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumYOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumZOperatorRightHandSidePointer->setVelocity( velocity ); + this->energyOperatorRightHandSidePointer->setVelocity( velocity ); + this->turbulentEnergyOperatorRightHandSidePointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->turbulentEnergyOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->momentumXOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + this->turbulentEnergyOperatorRightHandSidePointer->setTurbulentEnergy( turbulentEnergy ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorRightHandSidePointer->setDensity( density ); + this->momentumYOperatorRightHandSidePointer->setDensity( density ); + this->momentumZOperatorRightHandSidePointer->setDensity( density ); + this->energyOperatorRightHandSidePointer->setDensity( density ); + this->turbulentEnergyOperatorRightHandSidePointer->setDenity( density ); + } + + const ContinuityOperatorRightHandSidePointer& getContinuityOperatorRightHandSide() const + { + return this->continuityOperatorRightHandSidePointer; + } + + const MomentumXOperatorRightHandSidePointer& getMomentumXOperatorRightHandSide() const + { + return this->momentumXOperatorRightHandSidePointer; + } + + const MomentumYOperatorRightHandSidePointer& getMomentumYOperatorRightHandSide() const + { + return this->momentumYOperatorRightHandSidePointer; + } + + const MomentumZOperatorRightHandSidePointer& getMomentumZOperatorRightHandSide() const + { + return this->momentumZOperatorRightHandSidePointer; + } + + const EnergyOperatorRightHandSidePointer& getEnergyOperatorRightHandSide() const + { + return this->energyOperatorRightHandSidePointer; + } + + const TurbulentEnergyOperatorRightHandSidePointer& getTurbulentEnergyOperatorRightHandSide() const + { + return this->turbulentEnergyOperatorRightHandSidePointer; + } + + const DisipationOperatorRightHandSidePointer& getDisipationOperatorRightHandSide() const + { + return this->disipationOperatorRightHandSidePointer; + } + + protected: + + ContinuityOperatorRightHandSidePointer continuityOperatorPointer; + MomentumXOperatorRightHandSidePointer momentumXOperatorPointer; + MomentumYOperatorRightHandSidePointer momentumYOperatorPointer; + MomentumZOperatorRightHandSidePointer momentumZOperatorPointer; + EnergyOperatorRightHandSidePointer energyOperatorPointer; + TurbulentEnergyOperatorRightHandSidePointer turbulentEnergyOperatorPointer; + DisipationOperatorRightHandSidePointer disipationOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaTurbulentEnergyOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaTurbulentEnergyOperatorRightHandSide.h new file mode 100644 index 000000000..de2a655ce --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaTurbulentEnergyOperatorRightHandSide.h @@ -0,0 +1,553 @@ +/*************************************************************************** + KOmegaTurbulentEnergyOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaTurbulentEnergyRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + + + static String getType() + { + return String( "LaxFridrichsTurbulentEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + void setSigmaK( const RealType& sigmaK ) + { + this->sigmaK = sigmaK; + } + + void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) + { + this->turbulentEnergy = turbulentEnergy; + } + + void setDisipation( const MeshFunctionPointer& disipation ) + { + this->disipation = disipation; + } + + void setBetaStar( const RealType& betaStar ) + { + this->betaStar = betaStar; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + MeshFunctionPointer turbulentEnergy; + + MeshFunctionPointer disipation; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; + + RealType sigmaK; + + RealType betaStar; +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class KOmegaTurbulentEnergyRightHandSide +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaTurbulentEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaTurbulentEnergyRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaTurbulentEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + + const RealType& disipation_center = this->disipation.template getData< DeviceType >()[ center ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return + 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - + this->betaStar * turbulentEnergy_center * disipation_center + + + this->dynamicalViscosity + * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) + * hxSquareInverse + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + ) * hxSquareInverse * this->sigmaK; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaTurbulentEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaTurbulentEnergyRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaTurbulentEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + + const RealType& disipation_center = this->disipation.template getData< DeviceType >()[ center ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return + ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + + ( ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - + this->betaStar * turbulentEnergy_center * disipation_center + + + this->dynamicalViscosity + * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) + * hySquareInverse + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + ) * hySquareInverse * this->sigmaK + + + this->dynamicalViscosity + * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) + * hxSquareInverse + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + ) * hxSquareInverse * this->sigmaK; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class KOmegaTurbulentEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public KOmegaTurbulentEnergyRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef KOmegaTurbulentEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; + const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; + const RealType& turbulentEnergy_north = this->turbulentEnergy.template getData< DeviceType >()[ north ]; + const RealType& turbulentEnergy_south = this->turbulentEnergy.template getData< DeviceType >()[ south ]; + const RealType& turbulentEnergy_up = this->turbulentEnergy.template getData< DeviceType >()[ up ]; + const RealType& turbulentEnergy_down = this->turbulentEnergy.template getData< DeviceType >()[ down ]; + + const RealType& disipation_center = this->disipation.template getData< DeviceType >()[ center ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_x_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 +// vT_12_x + + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_east - velocity_y_west ) * hxInverse / 2 +// wT_13_x + + ( ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_z_east - velocity_z_west ) * hxInverse / 2 +// uT_21_y + + ( ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + + ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_north - velocity_x_south ) * hyInverse / 2 +// 3D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 +// wT_23_y + + ( ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + + ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_z_north - velocity_z_south ) * hyInverse / 2 +// uT_31_z + + ( ( velocity_x_up - velocity_x_down ) * hzInverse / 2 + + ( velocity_z_east - velocity_z_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_x_up - velocity_x_down ) * hzInverse / 2 +// T_32_z + + ( ( velocity_z_north - velocity_z_south ) * hyInverse / 2 + + ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_y_up - velocity_y_down ) * hzInverse / 2 +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ) * this->dynamicalViscosity + * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + - + this->betaStar * turbulentEnergy_center * disipation_center + + + this->dynamicalViscosity + * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) + * hxSquareInverse + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + ) * hxSquareInverse * this->sigmaK + + + this->dynamicalViscosity + * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) + * hySquareInverse + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + ) * hySquareInverse * this->sigmaK + + + this->dynamicalViscosity + * ( turbulentEnergy_up - 2 * turbulentEnergy_center + turbulentEnergy_down ) + * hySquareInverse + + ( turbulentEnergy_up * turbulentViscosity_up - turbulentEnergy_center * turbulentViscosity_down + - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_down * turbulentViscosity_down + ) * hySquareInverse * this->sigmaK; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/PhysicalVariablesGetter.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/PhysicalVariablesGetter.h new file mode 100644 index 000000000..452620d0d --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/PhysicalVariablesGetter.h @@ -0,0 +1,243 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { + +template< typename Mesh > +class PhysicalVariablesGetter +{ + public: + + typedef Mesh MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + VelocityGetter( MeshFunctionPointer density, + MeshFunctionPointer momentum ) + : density( density ), momentum( momentum ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return momentum.template getData< DeviceType >()( meshEntity ) / + density.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, momentum; + }; + + class PressureGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + PressureGetter( MeshFunctionPointer density, + MeshFunctionPointer energy, + VelocityFieldPointer momentum, + const RealType& gamma ) + : density( density ), energy( energy ), momentum( momentum ), gamma( gamma ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + const RealType e = energy.template getData< DeviceType >()( meshEntity ); + const RealType rho = density.template getData< DeviceType >()( meshEntity ); + const RealType momentumNorm = momentum.template getData< DeviceType >().getVector( meshEntity ).lpNorm( 2.0 ); + if( rho == 0.0 ) + return 0; + else + return ( gamma - 1.0 ) * ( e - 0.5 * momentumNorm * momentumNorm / rho ); + } + + protected: + const MeshFunctionPointer density, energy; + const VelocityFieldPointer momentum; + const RealType gamma; + }; + + class TurbulentEnergyGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + TurbulentEnergyGetter( MeshFunctionPointer density, + MeshFunctionPointer turbulentEnergyXDensity ) + : density( density ), turbulentEnergyXDensity( turbulentEnergyXDensity ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return turbulentEnergyXDensity.template getData< DeviceType >()( meshEntity ) / + density.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, turbulentEnergyXDensity; + }; + + class DisipationGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + DisipationGetter( MeshFunctionPointer density, + MeshFunctionPointer disipationXDensity ) + : density( density ), disipationXDensity( disipationXDensity ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return disipationXDensity.template getData< DeviceType >()( meshEntity ) / + density.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, disipationXDensity; + }; + + class TurbulentViscosityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + TurbulentViscosityGetter( MeshFunctionPointer density, + MeshFunctionPointer turbulentEnergy, + RealType turbulenceConstant, + MeshFunctionPointer disipation ) + : density( density ), turbulentEnergy( turbulentEnergy ), turbulenceConstant( turbulenceConstant ), disipation( disipation ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( disipation.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return density.template getData< DeviceType >()( meshEntity ) * turbulenceConstant + * turbulentEnergy.template getData< DeviceType >()( meshEntity ) + * turbulentEnergy.template getData< DeviceType >()( meshEntity ) + / disipation.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, turbulentEnergy, disipation; + const RealType turbulenceConstant; + }; + + + void getVelocity( const ConservativeVariablesPointer& conservativeVariables, + VelocityFieldPointer& velocity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), + ( *conservativeVariables->getMomentum() )[ i ] ); + evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); + } + } + + void getPressure( const ConservativeVariablesPointer& conservativeVariables, + const RealType& gamma, + MeshFunctionPointer& pressure ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; + Pointers::SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), + conservativeVariables->getEnergy(), + conservativeVariables->getMomentum(), + gamma ); + evaluator.evaluate( pressure, pressureGetter ); + } + + void getTurbulentEnergy( const ConservativeVariablesPointer& conservativeVariables, + MeshFunctionPointer& turbulentEnergy_no_rho ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, TurbulentEnergyGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< TurbulentEnergyGetter, DeviceType > turbulentEnergyGetter( conservativeVariables->getDensity(), + conservativeVariables->getTurbulentEnergy() ); + evaluator.evaluate( turbulentEnergy_no_rho, turbulentEnergyGetter ); + } + } + + void getDisipation( const ConservativeVariablesPointer& conservativeVariables, + MeshFunctionPointer& disipation_no_rho ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, DisipationGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< DisipationGetter, DeviceType > disipationGetter( conservativeVariables->getDensity(), + conservativeVariables->getDisipation() ); + evaluator.evaluate( disipation_no_rho, disipationGetter ); + } + } + + void getTurbulentViscosity( const ConservativeVariablesPointer& conservativeVariables, + MeshFunctionPointer& turbulentEnergy_no_rho, + MeshFunctionPointer& disipation_no_rho, + const RealType& turbulenceConstant, + MeshFunctionPointer& turbulentViscosity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, TurbulentViscosityGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< TurbulentViscosityGetter, DeviceType > turbulentViscosityGetter( conservativeVariables->getDensity(), + turbulentEnergy_no_rho, + turbulenceConstant, + disipation_no_rho); + evaluator.evaluate( turbulentViscosity, turbulentViscosityGetter ); + } + } + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/RiemannProblemInitialCondition.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/RiemannProblemInitialCondition.h new file mode 100644 index 000000000..90a456fb4 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/RiemannProblemInitialCondition.h @@ -0,0 +1,1896 @@ +/*************************************************************************** + RiemannProblemInitialCondition.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { +template +class RiemannProblemInitialConditionSetter +{ + +}; + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 1,MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setTurbulentEnergy(RealType NWUTurbulentEnergy, + RealType NEUTurbulentEnergy, + RealType SWUTurbulentEnergy, + RealType SEUTurbulentEnergy, + RealType NWDTurbulentEnergy, + RealType NEDTurbulentEnergy, + RealType SWDTurbulentEnergy, + RealType SEDTurbulentEnergy) + { + this->NWUTurbulentEnergy = NWUTurbulentEnergy; + this->NEUTurbulentEnergy = NEUTurbulentEnergy; + this->SWUTurbulentEnergy = SWUTurbulentEnergy; + this->SEUTurbulentEnergy = SEUTurbulentEnergy; + this->NWDTurbulentEnergy = NWDTurbulentEnergy; + this->NEDTurbulentEnergy = NEDTurbulentEnergy; + this->SWDTurbulentEnergy = SWDTurbulentEnergy; + this->SEDTurbulentEnergy = SEDTurbulentEnergy; + }; + + void setDisipation(RealType NWUDisipation, + RealType NEUDisipation, + RealType SWUDisipation, + RealType SEUDisipation, + RealType NWDDisipation, + RealType NEDDisipation, + RealType SWDDisipation, + RealType SEDDisipation) + { + this->NWUDisipation = NWUDisipation; + this->NEUDisipation = NEUDisipation; + this->SWUDisipation = SWUDisipation; + this->SEUDisipation = SEUDisipation; + this->NWDDisipation = NWDDisipation; + this->NEDDisipation = NEDDisipation; + this->SWDDisipation = SWDDisipation; + this->SEDDisipation = SEDDisipation; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + }; + + + void placeTurbulentEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWDTurbulentEnergy); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEDTurbulentEnergy); + } + }; + + void placeDisipation(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SWDDisipation); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SEDDisipation); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + RealType NWUDisipation, NEUDisipation, SWUDisipation, SEUDisipation, NWDDisipation, NEDDisipation, SWDDisipation, SEDDisipation; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 2,MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setTurbulentEnergy(RealType NWUTurbulentEnergy, + RealType NEUTurbulentEnergy, + RealType SWUTurbulentEnergy, + RealType SEUTurbulentEnergy, + RealType NWDTurbulentEnergy, + RealType NEDTurbulentEnergy, + RealType SWDTurbulentEnergy, + RealType SEDTurbulentEnergy) + { + this->NWUTurbulentEnergy = NWUTurbulentEnergy; + this->NEUTurbulentEnergy = NEUTurbulentEnergy; + this->SWUTurbulentEnergy = SWUTurbulentEnergy; + this->SEUTurbulentEnergy = SEUTurbulentEnergy; + this->NWDTurbulentEnergy = NWDTurbulentEnergy; + this->NEDTurbulentEnergy = NEDTurbulentEnergy; + this->SWDTurbulentEnergy = SWDTurbulentEnergy; + this->SEDTurbulentEnergy = SEDTurbulentEnergy; + }; + + void setDisipation(RealType NWUDisipation, + RealType NEUDisipation, + RealType SWUDisipation, + RealType SEUDisipation, + RealType NWDDisipation, + RealType NEDDisipation, + RealType SWDDisipation, + RealType SEDDisipation) + { + this->NWUDisipation = NWUDisipation; + this->NEUDisipation = NEUDisipation; + this->SWUDisipation = SWUDisipation; + this->SEUDisipation = SEUDisipation; + this->NWDDisipation = NWDDisipation; + this->NEDDisipation = NEDDisipation; + this->SWDDisipation = SWDDisipation; + this->SEDDisipation = SEDDisipation; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); + } + }; + + void placeTurbulentEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEDTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NEDTurbulentEnergy); + } + }; + + void placeDisipation(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SWDDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SEDDisipation); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->NWDDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->NEDDisipation); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + RealType NWUDisipation, NEUDisipation, SWUDisipation, SEUDisipation, NWDDisipation, NEDDisipation, SWDDisipation, SEDDisipation; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setTurbulentEnergy(RealType NWUTurbulentEnergy, + RealType NEUTurbulentEnergy, + RealType SWUTurbulentEnergy, + RealType SEUTurbulentEnergy, + RealType NWDTurbulentEnergy, + RealType NEDTurbulentEnergy, + RealType SWDTurbulentEnergy, + RealType SEDTurbulentEnergy) + { + this->NWUTurbulentEnergy = NWUTurbulentEnergy; + this->NEUTurbulentEnergy = NEUTurbulentEnergy; + this->SWUTurbulentEnergy = SWUTurbulentEnergy; + this->SEUTurbulentEnergy = SEUTurbulentEnergy; + this->NWDTurbulentEnergy = NWDTurbulentEnergy; + this->NEDTurbulentEnergy = NEDTurbulentEnergy; + this->SWDTurbulentEnergy = SWDTurbulentEnergy; + this->SEDTurbulentEnergy = SEDTurbulentEnergy; + }; + + void setDisipation(RealType NWUDisipation, + RealType NEUDisipation, + RealType SWUDisipation, + RealType SEUDisipation, + RealType NWDDisipation, + RealType NEDDisipation, + RealType SWDDisipation, + RealType SEDDisipation) + { + this->NWUDisipation = NWUDisipation; + this->NEUDisipation = NEUDisipation; + this->SWUDisipation = SWUDisipation; + this->SEUDisipation = SEUDisipation; + this->NWDDisipation = NWDDisipation; + this->NEDDisipation = NEDDisipation; + this->SWDDisipation = SWDDisipation; + this->SEDDisipation = SEDDisipation; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWDMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEDMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NWDMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NEDMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); + } + }; + + void placeTurbulentEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEDTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NWDTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->NEDTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWUTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEUTurbulentEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SWUTurbulentEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getTurbulentEnergy()).setValue(cell, this->SEUTurbulentEnergy); + } + }; + + void placeDisipation(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SWDDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SEDDisipation); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->NWDDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->NEDDisipation); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SWUDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SEUDisipation); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SWUDisipation); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDisipation()).setValue(cell, this->SEUDisipation); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + RealType NWUDisipation, NEUDisipation, SWUDisipation, SEUDisipation, NWDDisipation, NEDDisipation, SWDDisipation, SEDDisipation; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + +template< typename Mesh > +class RiemannProblemInitialCondition +{ + public: + + typedef Mesh MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; + + RiemannProblemInitialCondition() + : discontinuityPlacement( 0.5 ), + leftDensity( 1.0 ), rightDensity( 1.0 ), + leftVelocity( -2.0 ), rightVelocity( 2.0 ), + leftPressure( 0.4 ), rightPressure( 0.4 ), + gamma( 1.67 ){} + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "discontinuity-placement-0", "x-coordinate of the discontinuity placement.", 0.5 ); + config.addEntry< double >( prefix + "discontinuity-placement-1", "y-coordinate of the discontinuity placement.", 0.5 ); + config.addEntry< double >( prefix + "discontinuity-placement-2", "z-coordinate of the discontinuity placement.", 0.5 ); +/* + config.addEntry< double >( prefix + "left-density", "Density on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-density", "Density on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "left-velocity-0", "x-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "left-velocity-1", "y-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "left-velocity-2", "z-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-velocity-0", "x-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "right-velocity-1", "y-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "right-velocity-2", "z-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "left-pressure", "Pressure on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-pressure", "Pressure on the right side of the discontinuity.", 0.0 ); +*/ + config.addEntry< double >( prefix + "NWU-density", "This sets a value of northwest up density.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-0", "This sets a value of northwest up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-1", "This sets a value of northwest up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-2", "This sets a value of northwest up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-pressure", "This sets a value of northwest up pressure.", 1.0 ); + config.addEntry< double >( prefix + "SWU-density", "This sets a value of southwest up density.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-0", "This sets a value of southwest up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-1", "This sets a value of southwest up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-2", "This sets a value of southwest up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-pressure", "This sets a value of southwest up pressure.", 1.0 ); + config.addEntry< double >( prefix + "NWD-density", "This sets a value of northwest down density.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-0", "This sets a value of northwest down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-1", "This sets a value of northwest down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-2", "This sets a value of northwest down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-pressure", "This sets a value of northwest down pressure.", 1.0 ); + config.addEntry< double >( prefix + "SWD-density", "This sets a value of southwest down density.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-0", "This sets a value of southwest down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-1", "This sets a value of southwest down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-2", "This sets a value of southwest down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-pressure", "This sets a value of southwest down pressure.", 1.0 ); + config.addEntry< double >( prefix + "NEU-density", "This sets a value of northeast up density.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-0", "This sets a value of northeast up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-1", "This sets a value of northeast up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-2", "This sets a value of northeast up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-pressure", "This sets a value of northeast up pressure.", 1.0 ); + config.addEntry< double >( prefix + "SEU-density", "This sets a value of southeast up density.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-0", "This sets a value of southeast up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-1", "This sets a value of southeast up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-2", "This sets a value of southeast up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-pressure", "This sets a value of southeast up pressure.", 1.0 ); + config.addEntry< double >( prefix + "NED-density", "This sets a value of northeast down density.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-0", "This sets a value of northeast down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-1", "This sets a value of northeast down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-2", "This sets a value of northeast down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-pressure", "This sets a value of northeast down pressure.", 1.0 ); + config.addEntry< double >( prefix + "SED-density", "This sets a value of southeast down density.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-0", "This sets a value of southeast down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-1", "This sets a value of southeast down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-2", "This sets a value of southeast down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-pressure", "This sets a value of southeast down pressure.", 1.0 ); + config.addEntry< double >( prefix + "gamma", "Gamma in the ideal gas state equation.", 1.4 ); + + config.addEntry< String >( prefix + "initial", " One of predefined initial condition.", "none"); + config.addEntryEnum< String >( "none" ); + config.addEntryEnum< String >( "1D_2" ); + config.addEntryEnum< String >( "1D_3a" ); + config.addEntryEnum< String >( "1D_4" ); + config.addEntryEnum< String >( "1D_5" ); + config.addEntryEnum< String >( "1D_6" ); + config.addEntryEnum< String >( "1D_Noh" ); + config.addEntryEnum< String >( "1D_peak" ); + config.addEntryEnum< String >( "2D_3" ); + config.addEntryEnum< String >( "2D_4" ); + config.addEntryEnum< String >( "2D_6" ); + config.addEntryEnum< String >( "2D_12" ); + config.addEntryEnum< String >( "2D_15" ); + config.addEntryEnum< String >( "2D_17" ); + } + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + String initial = parameters.getParameter< String >( prefix + "initial" ); + if(initial == prefix + "none") + { + this->intensity = parameters.getParameter< double >( "turbulence-intensity" ); + this->turbulenceConstant = parameters.getParameter< double >( "turbulence-constant" ); + this->lengthScale = parameters.getParameter< double >( "turbulence-length-scale" ); + this->discontinuityPlacement.setup( parameters, prefix + "discontinuity-placement-" ); + this->gamma = parameters.getParameter< double >( prefix + "gamma" ); +/* + this->leftVelocity.setup( parameters, prefix + "left-velocity-" ); + this->rightVelocity.setup( parameters, prefix + "right-velocity-" ); + this->leftDensity = parameters.getParameter< double >( prefix + "left-density" ); + this->rightDensity = parameters.getParameter< double >( prefix + "right-density" ); + this->leftPressure = parameters.getParameter< double >( prefix + "left-pressure" ); + this->rightPressure = parameters.getParameter< double >( prefix + "right-pressure" ); +*/ + + this->NWUDensity = parameters.getParameter< RealType >( prefix + "NWU-density" ); + this->NWUVelocity.setup( parameters, prefix + "NWU-velocity-" ); + this->NWUPressure = parameters.getParameter< RealType >( prefix + "NWU-pressure" ); + this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); + this->NWUMomentum = NWUVelocity * NWUDensity; + this->NWUTurbulentEnergy = this->NWUDensity * TurbulentEnergy( NWUVelocity, this->intensity); + this->NWUDisipation = this->turbulenceConstant * std::pow( NWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); + this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); + this->SWUPressure = parameters.getParameter< RealType >( prefix + "SWU-pressure" ); + this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); + this->SWUMomentum = SWUVelocity * SWUDensity; + this->SWUTurbulentEnergy = SWUDensity * TurbulentEnergy( SWUVelocity, this->intensity); + this->SWUDisipation = this->turbulenceConstant * std::pow( SWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); + this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); + this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); + this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); + this->NWDMomentum = NWDVelocity * NWDDensity; + this->NWDTurbulentEnergy = NWDDensity * TurbulentEnergy( NWDVelocity, this->intensity); + this->NWDDisipation = this->turbulenceConstant * std::pow( NWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); + this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); + this->SWDPressure = parameters.getParameter< RealType >( prefix + "SWD-pressure" ); + this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); + this->SWDMomentum = SWDVelocity * SWDDensity; + this->SWDTurbulentEnergy = SWDDensity * TurbulentEnergy( SWDVelocity, this->intensity); + this->SWDDisipation = this->turbulenceConstant * std::pow( SWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); + this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); + this->NEUPressure = parameters.getParameter< RealType >( prefix + "NEU-pressure" ); + this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); + this->NEUMomentum = NEUVelocity * NEUDensity; + this->NEUTurbulentEnergy = NEUDensity * TurbulentEnergy( NEUVelocity, this->intensity); + this->NEUDisipation = this->turbulenceConstant * std::pow( NEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); + this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); + this->SEUPressure = parameters.getParameter< RealType >( prefix + "SEU-pressure" ); + this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); + this->SEUMomentum = SEUVelocity * SEUDensity; + this->SEUTurbulentEnergy = SEUDensity * TurbulentEnergy( SEUVelocity, this->intensity); + this->SEUDisipation = this->turbulenceConstant * std::pow( SEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); + this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); + this->NEDPressure = parameters.getParameter< RealType >( prefix + "NED-pressure" ); + this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); + this->NEDMomentum = NEDVelocity * NEDDensity; + this->NEDTurbulentEnergy = NEDDensity * TurbulentEnergy( NEDVelocity, this->intensity); + this->NEDDisipation = this->turbulenceConstant * std::pow( NEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); + this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); + this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); + this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); + this->SEDMomentum = SEDVelocity * SEDDensity; + this->SEDTurbulentEnergy = SEDDensity * TurbulentEnergy( SEDVelocity, this->intensity); + this->SEDDisipation = this->turbulenceConstant * std::pow( SEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + } + if(initial == prefix + "1D_2") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -2.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 2.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_3a") + predefinedInitialCondition( 1.4, 0.8, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 1000.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.01, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -19.59745, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -19.59745, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_4") + predefinedInitialCondition( 1.666, 0.4, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 5.99924, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 5.99242, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 460.894, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 46.095, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 19.5975, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -6.19633, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_5") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_6") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.1, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_Noh") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.000001, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.000001, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_peak") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 0.12612, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 6.5915, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 782.929, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 3.15449, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 8.90470, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 2.26542, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_3") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5323, 0.138, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.5, 0.5323, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.3, 0.029, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.5, 0.3, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 1.206, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.206, 1.206, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 1.206, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_4") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5065, 1.1, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.1, 0.5065, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.35, 1.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.1, 0.35, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.8939, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.8939, 0.8939, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.8939, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + + if(initial == prefix + "2D_6") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 2.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 3.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.75, 0.5, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -0.75, 0.5, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.75, -0.5, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -0.75, -0.5, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_12") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 1.0, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.5313, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.4, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.7276, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.7276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + + if(initial == prefix + "2D_15") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5197, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 0.5313, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.4, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + -0.6259, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.1, -0.3, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.1, -0.3, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.1, 0.4276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_17") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 2.0, 1.0625, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 0.5197, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.2145, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, -0.4, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 1.1259, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + return true; + } + + void setDiscontinuityPlacement( const PointType& v ) + { + this->discontinuityPlacement = v; + } + + const PointType& getDiscontinuityPlasement() const + { + return this->discontinuityPlacement; + } + + void setLeftDensity( const RealType& leftDensity ) + { + this->leftDensity = leftDensity; + } + + const RealType& getLeftDensity() const + { + return this->leftDensity; + } + + void setRightDensity( const RealType& rightDensity ) + { + this->rightDensity = rightDensity; + } + + const RealType& getRightDensity() const + { + return this->rightDensity; + } + + void setLeftVelocity( const PointType& leftVelocity ) + { + this->leftVelocity = leftVelocity; + } + + const PointType& getLeftVelocity() const + { + return this->leftVelocity; + } + + void setRightVelocity( const RealType& rightVelocity ) + { + this->rightVelocity = rightVelocity; + } + + const PointType& getRightVelocity() const + { + return this->rightVelocity; + } + + void setLeftPressure( const RealType& leftPressure ) + { + this->leftPressure = leftPressure; + } + + const RealType& getLeftPressure() const + { + return this->leftPressure; + } + + void setRightPressure( const RealType& rightPressure ) + { + this->rightPressure = rightPressure; + } + + const RealType& getRightPressure() const + { + return this->rightPressure; + } + + + void predefinedInitialCondition( double preGamma, double preDiscX, double preDiscY, double preDiscZ, + double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ) + + { + this->intensity = 1.0; + this->turbulenceConstant = 1.0; + this->lengthScale = 1.0; + this->discontinuityPlacement = PointLoad(preDiscX, preDiscY, preDiscZ); + this->gamma = preGamma; + + this->NWUDensity = preNWUDensity; + this->NWUVelocity = PointLoad(preNWUVelocityX, preNWUVelocityY, preNWUVelocityZ); + this->NWUPressure = preNWUPressure; + this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); + this->NWUMomentum = NWUVelocity * NWUDensity; + this->NWUTurbulentEnergy = NWUDensity * TurbulentEnergy( NWUVelocity, this->intensity); + this->NWUDisipation = this->turbulenceConstant * std::pow( NWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SWUDensity = preNWUDensity; + this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); + this->SWUPressure = preSWUPressure; + this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); + this->SWUMomentum = SWUVelocity * SWUDensity; + this->SWUTurbulentEnergy = SWUDensity * TurbulentEnergy( SWUVelocity, this->intensity); + this->SWUDisipation = this->turbulenceConstant * std::pow( SWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NWDDensity = preNWDDensity; + this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); + this->NWDPressure = preNWDPressure; + this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); + this->NWDMomentum = NWDVelocity * NWDDensity; + this->NWDTurbulentEnergy = NWDDensity * TurbulentEnergy( NWDVelocity, this->intensity); + this->NWDDisipation = this->turbulenceConstant * std::pow( NWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SWDDensity = preSWDDensity; + this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); + this->SWDPressure = preSWDPressure; + this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); + this->SWDMomentum = SWDVelocity * SWDDensity; + this->SWDTurbulentEnergy = SWDDensity * TurbulentEnergy( SWDVelocity, this->intensity); + this->SWDDisipation = this->turbulenceConstant * std::pow( SWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NEUDensity = preNEUDensity; + this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); + this->NEUPressure = preNEUPressure; + this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); + this->NEUMomentum = NEUVelocity * NEUDensity; + this->NEUTurbulentEnergy = NEUDensity * TurbulentEnergy( NEUVelocity, this->intensity); + this->NEUDisipation = this->turbulenceConstant * std::pow( NEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SEUDensity = preSEUDensity; + this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); + this->SEUPressure = preSEUPressure; + this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); + this->SEUMomentum = SEUVelocity * SEUDensity; + this->SEUTurbulentEnergy = TurbulentEnergy( SEUVelocity, this->intensity); + this->SEUDisipation = this->turbulenceConstant * std::pow( SEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->NEDDensity = preNEDDensity; + this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); + this->NEDPressure = preNEDPressure; + this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); + this->NEDMomentum = NEDVelocity * NEDDensity; + this->NEDTurbulentEnergy = NEDDensity * TurbulentEnergy( NEDVelocity, this->intensity); + this->NEDDisipation = this->turbulenceConstant * std::pow( NEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + this->SEDDensity = preSEDDensity; + this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); + this->SEDPressure = preSEDPressure; + this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); + this->SEDMomentum = SEDVelocity * SEDDensity; + this->SEDTurbulentEnergy = SEDDensity * TurbulentEnergy( SEDVelocity, this->intensity); + this->SEDDisipation = this->turbulenceConstant * std::pow( SEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + + } + + PointType PointLoad( RealType ValueX, RealType ValueY, RealType ValueZ) + { + PointType point; + switch (Dimensions) + { + case 1: point[ 0 ] = ValueX; + break; + case 2: point[ 0 ] = ValueX; + point[ 1 ] = ValueY; + break; + case 3: point[ 0 ] = ValueX; + point[ 1 ] = ValueY; + point[ 2 ] = ValueZ; + break; + } + return point; + } + + RealType Energy( RealType Density, RealType Pressure, RealType gamma, PointType Velocity) + { + RealType energy; + switch (Dimensions) + { + case 1: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ))); + break; + case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); + break; + case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 2 ], 2 ))); + break; // druhou mocninu ps8t jako sou4in + } + return energy; + } + + RealType TurbulentEnergy( PointType Velocity, RealType intensity ) + { + RealType turbulentEnergy; + switch (Dimensions) + { + case 1: turbulentEnergy = 3.0 / 2.0 * intensity * intensity * ((std::pow(Velocity[ 0 ], 2 ))); + break; + case 2: turbulentEnergy = 3.0 / 2.0 * intensity * intensity * ((std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); + break; + case 3: turbulentEnergy = 3.0 / 2.0 * intensity * intensity * ((std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 2 ], 2 ))); + break; // druhou mocninu ps8t jako sou4in + } + return turbulentEnergy; + } + + void setInitialCondition( CompressibleConservativeVariables< MeshType >& conservativeVariables, + const PointType& center = PointType( 0.0 ) ) + { + RiemannProblemInitialConditionSetter* variablesSetter = new RiemannProblemInitialConditionSetter; + variablesSetter->setGamma(this->gamma); + variablesSetter->setDensity(this->NWUDensity, + this->NEUDensity, + this->SWUDensity, + this->SEUDensity, + this->NWDDensity, + this->NEDDensity, + this->SWDDensity, + this->SEDDensity); + variablesSetter->setMomentum(this->NWUMomentum, + this->NEUMomentum, + this->SWUMomentum, + this->SEUMomentum, + this->NWDMomentum, + this->NEDMomentum, + this->SWDMomentum, + this->SEDMomentum); + variablesSetter->setEnergy(this->NWUEnergy, + this->NEUEnergy, + this->SWUEnergy, + this->SEUEnergy, + this->NWDEnergy, + this->NEDEnergy, + this->SWDEnergy, + this->SEDEnergy); + variablesSetter->setTurbulentEnergy(this->NWUTurbulentEnergy, + this->NEUTurbulentEnergy, + this->SWUTurbulentEnergy, + this->SEUTurbulentEnergy, + this->NWDTurbulentEnergy, + this->NEDTurbulentEnergy, + this->SWDTurbulentEnergy, + this->SEDTurbulentEnergy); + variablesSetter->setDisipation(this->NWUDisipation, + this->NEUDisipation, + this->SWUDisipation, + this->SEUDisipation, + this->NWDDisipation, + this->NEDDisipation, + this->SWDDisipation, + this->SEDDisipation); + variablesSetter->setDiscontinuity(this->discontinuityPlacement); + variablesSetter->placeDensity(conservativeVariables); + variablesSetter->placeMomentum(conservativeVariables); + variablesSetter->placeEnergy(conservativeVariables); + variablesSetter->placeTurbulentEnergy(conservativeVariables); + variablesSetter->placeDisipation(conservativeVariables); + +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + +/* + typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; + typedef Operators::Analytic::Sign< Dimensions, RealType > SignType; + typedef Functions::OperatorFunction< SignType, VectorNormType > InitialConditionType; + typedef SharedPointer< InitialConditionType, DeviceType > InitialConditionPointer; + + InitialConditionPointer initialCondition; + initialCondition->getFunction().setCenter( center ); + initialCondition->getFunction().setMaxNorm( true ); + initialCondition->getFunction().setRadius( discontinuityPlacement[ 0 ] ); + discontinuityPlacement *= 1.0 / discontinuityPlacement[ 0 ]; + for( int i = 1; i < Dimensions; i++ ) + discontinuityPlacement[ i ] = 1.0 / discontinuityPlacement[ i ]; + initialCondition->getFunction().setAnisotropy( discontinuityPlacement ); + initialCondition->getFunction().setMultiplicator( -1.0 ); + + Functions::MeshFunctionEvaluator< MeshFunctionType, InitialConditionType > evaluator; +*/ + /**** + * Density + */ +/* + conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); +*/ +/* + initialCondition->getOperator().setPositiveValue( leftDensity ); + initialCondition->getOperator().setNegativeValue( rightDensity ); + evaluator.evaluate( conservativeVariables.getDensity(), initialCondition ); + conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); +*/ + /**** + * Momentum + */ + +/* + for( int i = 0; i < Dimensions; i++ ) + { + initialCondition->getOperator().setPositiveValue( leftDensity * leftVelocity[ i ] ); + initialCondition->getOperator().setNegativeValue( rightDensity * rightVelocity[ i ] ); + evaluator.evaluate( conservativeVariables.getMomentum()[ i ], initialCondition ); + } +*/ + /**** + * Energy + */ +/* + conservativeVariables.getEnergy()->write( "energy-init", "gnuplot" ); +*/ +/* + const RealType leftKineticEnergy = leftVelocity.lpNorm( 2.0 ); + const RealType rightKineticEnergy = rightVelocity.lpNorm( 2.0 ); + const RealType leftEnergy = leftPressure / ( gamma - 1.0 ) + 0.5 * leftDensity * leftKineticEnergy * leftKineticEnergy; + const RealType rightEnergy = rightPressure / ( gamma - 1.0 ) + 0.5 * rightDensity * rightKineticEnergy * rightKineticEnergy; + initialCondition->getOperator().setPositiveValue( leftEnergy ); + initialCondition->getOperator().setNegativeValue( rightEnergy ); + evaluator.evaluate( (* conservativeVariables.getEnergy()), initialCondition ); + (* conservativeVariables.getEnergy())->write( "energy-init", "gnuplot" ); +*/ + } + + + protected: + + PointType discontinuityPlacement; + PointType NWUVelocity, NEUVelocity, SWUVelocity, SEUVelocity, NWDVelocity, NEDVelocity, SWDVelocity, SEDVelocity; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUPressure, NEUPressure, SWUPressure, SEUPressure, NWDPressure, NEDPressure, SWDPressure, SEDPressure; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType NWUTurbulentEnergy, NEUTurbulentEnergy, SWUTurbulentEnergy, SEUTurbulentEnergy; + RealType NWDTurbulentEnergy, NEDTurbulentEnergy, SWDTurbulentEnergy, SEDTurbulentEnergy; + RealType NWUDisipation, NEUDisipation, SWUDisipation, SEUDisipation, NWDDisipation, NEDDisipation, SWDDisipation, SEDDisipation; + RealType intensity; + RealType turbulenceConstant; + RealType lengthScale; + RealType leftDensity, rightDensity; + PointType leftVelocity, rightVelocity; + RealType leftPressure, rightPressure; + + RealType gamma; // gamma in the ideal gas state equation +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/flowsBuildConfigTag.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/flowsBuildConfigTag.h new file mode 100644 index 000000000..c40b793b9 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/flowsBuildConfigTag.h @@ -0,0 +1,72 @@ +#ifndef FLOWSBUILDCONFIGTAG_H_ +#define FLOWSBUILDCONFIGTAG_H_ + +#include +#include + +namespace TNL { + +class flowsBuildConfigTag{}; + +namespace Solvers { + +/**** + * Turn off support for float and long double. + */ +template<> struct ConfigTagReal< flowsBuildConfigTag, float > { enum { enabled = false }; }; +template<> struct ConfigTagReal< flowsBuildConfigTag, long double > { enum { enabled = false }; }; + +/**** + * Turn off support for short int and long int indexing. + */ +template<> struct ConfigTagIndex< flowsBuildConfigTag, short int >{ enum { enabled = false }; }; +template<> struct ConfigTagIndex< flowsBuildConfigTag, long int >{ enum { enabled = false }; }; + +//template< int Dimension > struct ConfigTagDimension< flowsBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; + +/**** + * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. + */ +/*template< int Dimension, typename Real, typename Device, typename Index > + struct ConfigTagMesh< flowsBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > + { enum { enabled = ConfigTagDimension< flowsBuildConfigTag, Dimension >::enabled && + ConfigTagReal< flowsBuildConfigTag, Real >::enabled && + ConfigTagDevice< flowsBuildConfigTag, Device >::enabled && + ConfigTagIndex< flowsBuildConfigTag, Index >::enabled }; }; +*/ +/**** + * Please, chose your preferred time discretisation here. + */ +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; + +/**** + * Only the Runge-Kutta-Merson solver is enabled by default. + */ +template<> struct ConfigTagExplicitSolver< flowsBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; + +} // namespace Solvers + +namespace Meshes { +namespace BuildConfigTags { + +template< int Dimensions > struct GridDimensionTag< flowsBuildConfigTag, Dimensions >{ enum { enabled = true }; }; + +/**** + * Turn off support for float and long double. + */ +template<> struct GridRealTag< flowsBuildConfigTag, float > { enum { enabled = false }; }; +template<> struct GridRealTag< flowsBuildConfigTag, long double > { enum { enabled = false }; }; + +/**** + * Turn off support for short int and long int indexing. + */ +template<> struct GridIndexTag< flowsBuildConfigTag, short int >{ enum { enabled = false }; }; +template<> struct GridIndexTag< flowsBuildConfigTag, long int >{ enum { enabled = false }; }; + +} // namespace BuildConfigTags +} // namespace Meshes +} // namespace TNL + +#endif /* FLOWSBUILDCONFIGTAG_H_ */ diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/flowsRhs.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/flowsRhs.h new file mode 100644 index 000000000..e0b8c7fac --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/flowsRhs.h @@ -0,0 +1,35 @@ +#ifndef FLOWSRHS_H_ +#define FLOWSRHS_H_ + +#include + +namespace TNL { + +template< typename Mesh, typename Real >class flowsRhs + : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > + { + public: + + typedef Mesh MeshType; + typedef Real RealType; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + template< typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshEntity& entity, + const Real& time = 0.0 ) const + { +// typedef typename MeshEntity::MeshType::PointType PointType; +// PointType v = entity.getCenter(); + return 0.0; + } +}; + +} //namespace TNL + +#endif /* FLOWSRHS_H_ */ diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model new file mode 100644 index 000000000..cd0c1bbb1 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-euler-navier-stokes + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --differential-operator Steger-Warming \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-AUSM-plus b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-AUSM-plus new file mode 100644 index 000000000..faaad26b4 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-AUSM-plus @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Ausm-Plus + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Lax-Friedrichs b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Lax-Friedrichs new file mode 100644 index 000000000..5f7bfbdc6 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Lax-Friedrichs @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Lax-Friedrichs + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Steger-Warming b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Steger-Warming new file mode 100644 index 000000000..1c3b5ba65 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Steger-Warming @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Steger-Warming + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Van-Leer b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Van-Leer new file mode 100644 index 000000000..1c3b5ba65 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/run-two-equation-turbulence-model-Van-Leer @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Steger-Warming + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.cpp b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.cpp new file mode 100644 index 000000000..a4f35360f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.cpp @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.cu b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.cu new file mode 100644 index 000000000..a4f35360f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.cu @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.h new file mode 100644 index 000000000..047a44e00 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModel.h @@ -0,0 +1,276 @@ +#include +#include +#include +#include +#include +#include "twoEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/Lax-Friedrichs/LaxFridrichs.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/Steger-Warming/StegerWarming.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/VanLeer/VanLeer.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/AUSM+/AUSMPlus.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class twoEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< String >( "differential-operator", "Choose the differential operator.", "Lax-Friedrichs"); + config.addEntryEnum< String >( "Lax-Friedrichs" ); + config.addEntryEnum< String >( "Steger-Warming" ); + config.addEntryEnum< String >( "VanLeer" ); + config.addEntryEnum< String >( "AUSMPlus" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class twoEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef twoEquationTurbulenceModelOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); + if( differentialOperatorType == "Lax-Friedrichs" ) + { + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "Steger-Warming" ) + { + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "VanLeer" ) + { + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "AUSMPlus" ) + { + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + + + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< twoEquationTurbulenceModelSetter, twoEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.cpp b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.cpp new file mode 100644 index 000000000..c9c751db2 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.cpp @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelAUSMPlus.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.cu b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.cu new file mode 100644 index 000000000..c9c751db2 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.cu @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelAUSMPlus.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h new file mode 100644 index 000000000..2641ae2e7 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h @@ -0,0 +1,145 @@ +//#include +#include +#include +#include +#include +#include +#include "twoEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/AUSM+/AUSMPlus.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class twoEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "turbulence-constant", "Value of turbulence constant", 1.0 ); + config.addEntry< double >( "viscosity-constant-1", "Value of viscosity constant C_epsilon_1", 1.0 ); + config.addEntry< double >( "viscosity-constant-2", "Value of viscosity constant C_epsilon_2", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "sigma-epsilon", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); + config.addEntry< double >( "turbulence-length-scale", "meassure of turbulence intensity", 1.0 ); + typedef Meshes::Grid< 3 > Mesh; + AUSMPlus< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class twoEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef KOmegaOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< twoEquationTurbulenceModelSetter, twoEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.cpp b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.cpp new file mode 100644 index 000000000..0a17eddc7 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.cpp @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelLaxFriedrichs.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.cu b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.cu new file mode 100644 index 000000000..0a17eddc7 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.cu @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelLaxFriedrichs.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h new file mode 100644 index 000000000..8b12e4c32 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h @@ -0,0 +1,145 @@ +//#include +#include +#include +#include +#include +#include +#include "twoEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/Lax-Friedrichs/LaxFridrichs.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class twoEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "turbulence-constant", "Value of turbulence constant", 1.0 ); + config.addEntry< double >( "viscosity-constant-1", "Value of viscosity constant C_epsilon_1", 1.0 ); + config.addEntry< double >( "viscosity-constant-2", "Value of viscosity constant C_epsilon_2", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "sigma-epsilon", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); + config.addEntry< double >( "turbulence-length-scale", "meassure of turbulence intensity", 1.0 ); + typedef Meshes::Grid< 3 > Mesh; + LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class twoEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef KOmegaOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< twoEquationTurbulenceModelSetter, twoEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem.h new file mode 100644 index 000000000..25a175179 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem.h @@ -0,0 +1,151 @@ +/*************************************************************************** + twoEquationTurbulenceModelProblem.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include "CompressibleConservativeVariables.h" + + +using namespace TNL::Problems; + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +class twoEquationTurbulenceModelProblem: + public PDEProblem< Mesh, + Communicator, + typename InviscidOperators::RealType, + typename Mesh::DeviceType, + typename InviscidOperators::IndexType > +{ + public: + + typedef typename InviscidOperators::RealType RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef typename InviscidOperators::IndexType IndexType; + typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; + + typedef Communicator CommunicatorType; + + using typename BaseType::MeshType; + using typename BaseType::MeshPointer; + using typename BaseType::DofVectorType; + using typename BaseType::DofVectorPointer; + static const int Dimensions = Mesh::getMeshDimension(); + + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; + typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; + typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; + + static String getType(); + + String getPrologHeader() const; + + void writeProlog( Logger& logger, + const Config::ParameterContainer& parameters ) const; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ); + + bool setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ); + + template< typename Matrix > + bool setupLinearSystem( Matrix& matrix ); + + bool makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ); + + IndexType getDofs() const; + + void bindDofs( DofVectorPointer& dofs ); + + void getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ); + + + void applyBoundaryConditions( const RealType& time, + DofVectorPointer& dofs ); + + template< typename Matrix > + void assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs, + Matrix& matrix, + DofVectorPointer& rightHandSide ); + + bool postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ); + + protected: + + InviscidOperatorsPointer inviscidOperatorsPointer; + + BoundaryConditionPointer boundaryConditionPointer; + RightHandSidePointer rightHandSidePointer; + + ConservativeVariablesPointer conservativeVariables, + conservativeVariablesRHS; + + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::ContinuityOperatorType, typename BoundaryCondition::DensityBoundaryConditionsType, RightHandSide > explicitUpdaterContinuity; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumXOperatorType, typename BoundaryCondition::MomentumXBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumX; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumYOperatorType, typename BoundaryCondition::MomentumYBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumY; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumZOperatorType, typename BoundaryCondition::MomentumZBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumZ; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::EnergyOperatorType, typename BoundaryCondition::EnergyBoundaryConditionsType, RightHandSide > explicitUpdaterEnergy; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::TurbulentEnergyOperatorType, typename BoundaryCondition::TurbulentEnergyBoundaryConditionsType, RightHandSide > explicitUpdaterTurbulentEnergy; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::DisipationOperatorType, typename BoundaryCondition::DisipationBoundaryConditionsType, RightHandSide > explicitUpdaterDisipation; + + + VelocityFieldPointer velocity; + MeshFunctionPointer pressure; + MeshFunctionPointer turbulentViscosity; + MeshFunctionPointer turbulentEnergy; + MeshFunctionPointer disipation; + + RealType gamma; + RealType speedIncrement; + RealType cavitySpeed; + RealType speedIncrementUntil; + RealType finalSpeed; + RealType startSpeed; + RealType speedIncrementUntilHThrottle; + RealType finalSpeedHThrottle; + RealType startSpeedHThrottle; + RealType turbulenceConstant; + RealType sigmaK; + RealType sigmaEpsilon; + RealType beta; + RealType betaStar; + RealType alpha; + RealType intensity; + RealType lengthScale; +}; + +} // namespace TNL + +#include "twoEquationTurbulenceModelProblem_impl.h" + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h new file mode 100644 index 000000000..4bdb5c017 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h @@ -0,0 +1,566 @@ +/*************************************************************************** + twoEquationTurbulenceModelProblem_impl.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "RiemannProblemInitialCondition.h" +#include "CompressibleConservativeVariables.h" +#include "PhysicalVariablesGetter.h" +#include "twoEquationTurbulenceModelProblem.h" + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getType() +{ + return String( "twoEquationTurbulenceModelProblem< " ) + Mesh :: getType() + " >"; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getPrologHeader() const +{ + return String( "flow solver" ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const +{ + /**** + * Add data you want to have in the computation report (log) as follows: + * logger.writeParameter< double >( "Parameter description", parameter ); + */ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setup( const Config::ParameterContainer& parameters, + const String& prefix ) +{ + if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || + ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || + ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) + return false; + this->gamma = parameters.getParameter< double >( "gamma" ); + this->startSpeed = parameters.getParameter< double >( "start-speed" ); + this->finalSpeed = parameters.getParameter< double >( "final-speed" ); + this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); + this->startSpeedHThrottle = parameters.getParameter< double >( "start-speed-h-throttle" ); + this->finalSpeedHThrottle = parameters.getParameter< double >( "final-speed-h-throttle" ); + this->speedIncrementUntilHThrottle = parameters.getParameter< RealType >( "speed-increment-until-h-throttle" ); + this->turbulenceConstant = parameters.getParameter< double >( "turbulence-constant" ); + this->beta = parameters.getParameter< double >( "beta" ); + this->betaStar = parameters.getParameter< double >( "beta-star" ); + this->alpha = parameters.getParameter< double >( "aplha" ); + this->sigmaK = parameters.getParameter< double >( "sigma-k" ); + this->sigmaEpsilon = parameters.getParameter< double >( "sigma-epsilon" ); + this->intensity = parameters.getParameter< double >( "turbulence-intensity" ); + this->lengthScale = parameters.getParameter< double >( "length-scale" ); + velocity->setMesh( this->getMesh() ); + pressure->setMesh( this->getMesh() ); + + /**** + * Set-up operators + */ + + this->inviscidOperatorsPointer->setSigmaK( this->sigmaK ); + this->inviscidOperatorsPointer->setSigmaEpsilon( this->sigmaEpsilon ); + this->inviscidOperatorsPointer->setBetaStar( this->betaStar ); + this->inviscidOperatorsPointer->setDisipation( this->disipation ); + this->inviscidOperatorsPointer->setVelocity( this->velocity ); + this->inviscidOperatorsPointer->setPressure( this->pressure ); + this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); + this->inviscidOperatorsPointer->setGamma( this->gamma ); + this->inviscidOperatorsPointer->setTurbulentViscosity( this->turbulentViscosity ); + this->inviscidOperatorsPointer->setTurbulentEnergy( this->turbulentEnergy ); + + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); + this->explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer->getDensityBoundaryCondition() ); + this->explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); + + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); + this->explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer->getMomentumXBoundaryCondition() ); + this->explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); + + if( Dimensions > 1 ) + { + this->explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); + this->explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer->getMomentumYBoundaryCondition() ); + this->explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); + this->explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer->getMomentumZBoundaryCondition() ); + this->explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); + this->explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer->getEnergyBoundaryCondition() ); + this->explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); + + /**** + * Turbulent energy equation + */ + this->explicitUpdaterTurbulentEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getTurbulentEnergyOperator() ); + this->explicitUpdaterTurbulentEnergy.setBoundaryConditions( this->boundaryConditionPointer->getTurbulentEnergyBoundaryCondition() ); + this->explicitUpdaterTurbulentEnergy.setRightHandSide( this->rightHandSidePointer ); + + /**** + * Disipation equation + */ + this->explicitUpdaterDisipation.setDifferentialOperator( this->inviscidOperatorsPointer->getDisipationOperator() ); + this->explicitUpdaterDisipation.setBoundaryConditions( this->boundaryConditionPointer->getDisipationBoundaryCondition() ); + this->explicitUpdaterDisipation.setRightHandSide( this->rightHandSidePointer ); + + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +typename twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >::IndexType +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getDofs() const +{ + /**** + * Return number of DOFs (degrees of freedom) i.e. number + * of unknowns to be resolved by the main solver. + */ + return this->conservativeVariables->getDofs( this->getMesh() ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +bindDofs( DofVectorPointer& dofVector ) +{ + this->conservativeVariables->bind( this->getMesh(), dofVector ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ) +{ + CompressibleConservativeVariables< MeshType > conservativeVariables; + conservativeVariables.bind( this->getMesh(), dofs ); + const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); + this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); + this->speedIncrement = parameters.getParameter< RealType >( "speed-increment" ); + this->cavitySpeed = parameters.getParameter< RealType >( "cavity-speed" ); + if( initialConditionType == "riemann-problem" ) + { + RiemannProblemInitialCondition< MeshType > initialCondition; + if( ! initialCondition.setup( parameters ) ) + return false; + initialCondition.setInitialCondition( conservativeVariables ); + return true; + } + std::cerr << "Unknown initial condition " << initialConditionType << std::endl; + return false; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +bool +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setupLinearSystem( Matrix& matrix ) +{ +/* const IndexType dofs = this->getDofs(); + typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; + CompressedRowLengthsVectorType rowLengths; + if( ! rowLengths.setSize( dofs ) ) + return false; + MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; + matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, + differentialOperator, + boundaryCondition, + rowLengths ); + matrix.setDimensions( dofs, dofs ); + if( ! matrix.setCompressedRowLengths( rowLengths ) ) + return false;*/ + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ) +{ + std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; + + this->bindDofs( dofs ); + PhysicalVariablesGetter< MeshType > physicalVariablesGetter; + physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + + FileName fileName; + fileName.setExtension( "tnl" ); + fileName.setIndex( step ); + fileName.setFileNameBase( "density-" ); +// if( ! this->conservativeVariables->getDensity()->save( fileName.getFileName() ) ) + this->conservativeVariables->getDensity()->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "velocity-" ); +// if( ! this->velocity->save( fileName.getFileName() ) ) + this->velocity->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "pressure-" ); +// if( ! this->pressure->save( fileName.getFileName() ) ) + this->pressure->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "energy-" ); +// if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) + this->conservativeVariables->getEnergy()->save( fileName.getFileName() ); +// return false; + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ) +{ + typedef typename MeshType::Cell Cell; + + /**** + * Bind DOFs + */ + this->conservativeVariables->bind( this->getMesh(), _u ); + this->conservativeVariablesRHS->bind( this->getMesh(), _fu ); + + /**** + * Resolve the physical variables + */ + PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; + physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + physicalVariables.getTurbulentEnergy( this->conservativeVariables, this->turbulentEnergy ); + physicalVariables.getDisipation( this->conservativeVariables, this->disipation ); +// physicalVariables.getTurbulentViscosity( this->conservativeVariables, this->turbulentEnergy, this->disipation, this->turbulenceConstant, this->turbulentViscosity ); + + /**** + * Set-up operators + */ + + this->inviscidOperatorsPointer->setTau( tau ); + + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getDensity(), + this->conservativeVariablesRHS->getDensity() ); + +// this->explicitUpdaterContinuity.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, +// this->conservativeVariables->getDensity() ); + + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); + if( Dimensions > 1 ) + { + this->explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getEnergy(), // uRhoVelocityX, + this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); + + + /**** + * Turbulent energy equation + */ + this->explicitUpdaterTurbulentEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getTurbulentEnergy(), // uRhoVelocityX, + this->conservativeVariablesRHS->getTurbulentEnergy() ); //, fuRhoVelocityX ); + + /**** + * Disipation equation + */ + this->explicitUpdaterTurbulentEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getDisipation(), // uRhoVelocityX, + this->conservativeVariablesRHS->getDisipation() ); //, fuRhoVelocityX ); + + /*this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); + this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); + this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); + getchar();*/ + +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +applyBoundaryConditions( const RealType& time, + DofVectorPointer& dofs ) +{ + /**** + * Update Boundary Conditions + */ + if(this->speedIncrementUntil > time ) + { + this->boundaryConditionPointer->setTimestep(this->speedIncrement); + } + else + { + this->boundaryConditionPointer->setTimestep(0); + } + this->boundaryConditionPointer->setIntensity(this->intensity); + this->boundaryConditionPointer->setLengthScale(this->lengthScale); + this->boundaryConditionPointer->setTurbulenceConstant(this->turbulenceConstant); + this->boundaryConditionPointer->setSpeed(this->cavitySpeed); + this->boundaryConditionPointer->setCompressibleConservativeVariables(this->conservativeVariables); + this->boundaryConditionPointer->setGamma(this->gamma); + this->boundaryConditionPointer->setPressure(this->pressure); + this->boundaryConditionPointer->setVerticalThrottleSpeed( startSpeed, finalSpeed, time, speedIncrementUntil ); + this->boundaryConditionPointer->setHorizontalThrottleSpeed( startSpeedHThrottle, finalSpeedHThrottle, time, speedIncrementUntilHThrottle ); + /**** + * Bind DOFs + */ + this->conservativeVariables->bind( this->getMesh(), dofs ); +// this->conservativeVariables->getDensity()->write( "density", "gnuplot" ); +// this->conservativeVariables->getEnergy()->write( "energy", "gnuplot" ); +// this->conservativeVariables->getMomentum()->write( "momentum", "gnuplot", 0.05 ); +// dofs->save("dofs.tnl"); +// getchar(); +// std::cout <<"applyBCC" << std::endl; + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getDensity() ); + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 0 ] ); // uRhoVelocityX, + if( Dimensions > 1 ) + { + + this->explicitUpdaterMomentumY.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 1 ] ); // uRhoVelocityX, + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 2 ] ); // uRhoVelocityX, + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getEnergy() ); // uRhoVelocityX, + + /**** + * Turbulent energy equation + */ + this->explicitUpdaterTurbulentEnergy.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getTurbulentEnergy() ); // uRhoVelocityX, + /**** + * Turbulent energy equation + */ + this->explicitUpdaterDisipation.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getDisipation() ); // uRhoVelocityX, + + +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +void +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + Matrix& matrix, + DofVectorPointer& b ) +{ +/* LinearSystemAssembler< Mesh, + MeshFunctionType, + InviscidOperators, + BoundaryCondition, + RightHandSide, + BackwardTimeDiscretisation, + Matrix, + DofVectorType > systemAssembler; + + MeshFunction< Mesh > u( mesh, _u ); + systemAssembler.template assembly< typename Mesh::Cell >( time, + tau, + this->differentialOperator, + this->boundaryCondition, + this->rightHandSide, + u, + matrix, + b );*/ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +twoEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ) +{ + /* + typedef typename MeshType::Cell Cell; + int count = mesh->template getEntitiesCount< Cell >()/4; + //bind _u + this->_uRho.bind( *dofs, 0, count); + this->_uRhoVelocityX.bind( *dofs, count, count); + this->_uRhoVelocityY.bind( *dofs, 2 * count, count); + this->_uEnergy.bind( *dofs, 3 * count, count); + + MeshFunctionType velocity( mesh, this->velocity ); + MeshFunctionType velocityX( mesh, this->velocityX ); + MeshFunctionType velocityY( mesh, this->velocityY ); + MeshFunctionType pressure( mesh, this->pressure ); + MeshFunctionType uRho( mesh, _uRho ); + MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); + MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); + MeshFunctionType uEnergy( mesh, _uEnergy ); + //Generating differential operators + Velocity euler2DVelocity; + VelocityX euler2DVelocityX; + VelocityY euler2DVelocityY; + Pressure euler2DPressure; + + //velocityX + euler2DVelocityX.setRhoVelX(uRhoVelocityX); + euler2DVelocityX.setRho(uRho); +// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; +// velocityX = OFVelocityX; + + //velocityY + euler2DVelocityY.setRhoVelY(uRhoVelocityY); + euler2DVelocityY.setRho(uRho); +// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; +// velocityY = OFVelocityY; + + //velocity + euler2DVelocity.setVelX(velocityX); + euler2DVelocity.setVelY(velocityY); +// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; +// velocity = OFVelocity; + + //pressure + euler2DPressure.setGamma(gamma); + euler2DPressure.setVelocity(velocity); + euler2DPressure.setEnergy(uEnergy); + euler2DPressure.setRho(uRho); +// OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure; +// pressure = OFPressure; + */ + return true; +} + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.cpp b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.cpp new file mode 100644 index 000000000..30a2938a7 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.cpp @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelStegerWarming.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.cu b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.cu new file mode 100644 index 000000000..30a2938a7 --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.cu @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelStegerWarming.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.h new file mode 100644 index 000000000..b1ea7746e --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.h @@ -0,0 +1,146 @@ +//#include +#include +#include +#include +#include +#include +#include "twoEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/Steger-Warming/StegerWarming.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class twoEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "turbulence-constant", "Value of turbulence constant", 1.0 ); + config.addEntry< double >( "beta", "Value of viscosity constant beta", 1.0 ); + config.addEntry< double >( "beta-star", "Value of viscosity constant beta_star", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "sigma-epsilon", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "alpha", "Value of alpha constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); + config.addEntry< double >( "turbulence-length-scale", "meassure of turbulence intensity", 1.0 ); + typedef Meshes::Grid< 3 > Mesh; + StegerWarming< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class twoEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef KOmegaOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< twoEquationTurbulenceModelSetter, twoEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.cpp b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.cpp new file mode 100644 index 000000000..2bd33e16a --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.cpp @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModelVanLeer.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.cu b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.cu new file mode 100644 index 000000000..a4f35360f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.cu @@ -0,0 +1 @@ +#include "twoEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h new file mode 100644 index 000000000..002ea592f --- /dev/null +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h @@ -0,0 +1,145 @@ +//#include +#include +#include +#include +#include +#include +#include "twoEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Two-Equation-Turbulence-Model/VanLeer/VanLeer.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class twoEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "turbulence-constant", "Value of turbulence constant", 1.0 ); + config.addEntry< double >( "viscosity-constant-1", "Value of viscosity constant C_epsilon_1", 1.0 ); + config.addEntry< double >( "viscosity-constant-2", "Value of viscosity constant C_epsilon_2", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "sigma-epsilon", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); + config.addEntry< double >( "turbulence-length-scale", "meassure of turbulence intensity", 1.0 ); + typedef Meshes::Grid< 3 > Mesh; + VanLeer< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class twoEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef KOmegaOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef twoEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< twoEquationTurbulenceModelSetter, twoEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h new file mode 100644 index 000000000..953199081 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/BoundaryConditionsBoiler.h @@ -0,0 +1,153 @@ +#include + +#include "DensityBoundaryConditionBoiler.h" +#include "MomentumXBoundaryConditionBoiler.h" +#include "MomentumYBoundaryConditionBoiler.h" +#include "MomentumZBoundaryConditionBoiler.h" +#include "EnergyBoundaryConditionBoiler.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsBoiler +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsBoiler< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h new file mode 100644 index 000000000..6231f6780 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/DensityBoundaryConditionBoiler.h @@ -0,0 +1,542 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().y() < 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().z() < 0.8 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionBoilers: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h new file mode 100644 index 000000000..412640b54 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/EnergyBoundaryConditionBoiler.h @@ -0,0 +1,853 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + + + this->cavitySpeed + * + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + + 0 + ) + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + * + this->cavitySpeed + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + * + this->cavitySpeed * ( -1 ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) +{ + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * + ( + ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( + this->cavitySpeed + * + this->cavitySpeed + ) + ); + + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h new file mode 100644 index 000000000..dfe63e076 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumXBoundaryConditionBoiler.h @@ -0,0 +1,594 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h new file mode 100644 index 000000000..83b6282dd --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumYBoundaryConditionBoiler.h @@ -0,0 +1,588 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) + &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed * ( -1 ) + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h new file mode 100644 index 000000000..9d887857c --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Boiler/MomentumZBoundaryConditionBoiler.h @@ -0,0 +1,563 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsBoiler +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsBoilerBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoiler< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) + &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoiler< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsBoiler: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h new file mode 100644 index 000000000..06228f789 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h @@ -0,0 +1,194 @@ +#include + +#include "DensityBoundaryConditionBoilerModel.h" +#include "MomentumXBoundaryConditionBoilerModel.h" +#include "MomentumYBoundaryConditionBoilerModel.h" +#include "MomentumZBoundaryConditionBoilerModel.h" +#include "EnergyBoundaryConditionBoilerModel.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsBoilerModel +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsBoilerModel< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "vertical-angle", "Vertical angle of throttle in degrees", 0 ); + config.addEntry< double >( prefix + "horizontal-angle", "Horizontal angle of throttle in degrees", 45 ); + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + setZAngle(parameters.getParameter< double >( prefix + "vertical-angle" ) * M_PI / 180.0 ); + setXYAngle(parameters.getParameter< double >( prefix + "horizontal-angle" ) * M_PI / 180.0 ); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setZAngle(const RealType zAngle) + { + this->densityBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumXBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumYBoundaryConditionsPointer->setZAngle(zAngle); + this->momentumZBoundaryConditionsPointer->setZAngle(zAngle); + this->energyBoundaryConditionsPointer->setZAngle(zAngle); + } + + void setXYAngle(const RealType xYAngle) + { + this->densityBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumXBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumYBoundaryConditionsPointer->setXYAngle(xYAngle); + this->momentumZBoundaryConditionsPointer->setXYAngle(xYAngle); + this->energyBoundaryConditionsPointer->setXYAngle(xYAngle); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + RealType horizontalThrottleSpeed = 0; + if(time <= finalTime) + if( time != 0 && finalTime != 0 ) + horizontalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) * ( time / finalTime ); + else + horizontalThrottleSpeed = 0; + else + horizontalThrottleSpeed = finalSpeed; + this->momentumXBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->momentumYBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->momentumZBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + this->energyBoundaryConditionsPointer->setHorizontalThrottleSpeed(horizontalThrottleSpeed); + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + RealType verticalThrottleSpeed = 0; + if(time <= finalTime) + if( time != 0 && finalTime != 0 ) + verticalThrottleSpeed = startSpeed + ( finalSpeed - startSpeed ) * ( time / finalTime ); + else + verticalThrottleSpeed = 0; + else + verticalThrottleSpeed = finalSpeed; + this->momentumXBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->momentumYBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->momentumZBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + this->energyBoundaryConditionsPointer->setVerticalThrottleSpeed(verticalThrottleSpeed); + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..a58f32f7c --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/DensityBoundaryConditionBoilerModel.h @@ -0,0 +1,580 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + if (entity.getCoordinates().y() < 0.835 * ( entity.getMesh().getDimensions().y() - 1 )) + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + // if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..d0475576b --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/EnergyBoundaryConditionBoilerModel.h @@ -0,0 +1,962 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle energy + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + }; + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle energy + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + if( (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] != 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * ( ( (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0 >()] + ) + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + ); + else return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->verticalThrottleSpeed + * + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ +const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; +// if for chimney exit + } + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + if( (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] != 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * ( ( (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 0 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 1 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + (* ( *this->compressibleConservativeVariables->getMomentum() )[ 2 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * (* ( *this->compressibleConservativeVariables->getMomentum() )[ 2 ] )[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + ) + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + ); + else return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * + this->horizontalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) +// &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->verticalThrottleSpeed + * + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType zAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..65648c389 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -0,0 +1,940 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +//throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->zAngle ) + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->zAngle ) + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + );*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..e8aa33e88 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumYBoundaryConditionBoilerModel.h @@ -0,0 +1,941 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +//throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( - 1.0 ) + * std::sin( this->zAngle ) + ); + } + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for y axis + if( + ( + ( entity.getCoordinates().y() < 0.45 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.44 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.43 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.42 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.41 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.40 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.38 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.37 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.36 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().y() < 0.35 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.34 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + ) +// throttle speed + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + } +// if for chimney exit + if( entity.getCoordinates().y() > 0.835 * ( entity.getMesh().getDimensions().y() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) +// down throttle + { + if( + ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) + && + ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) + ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + this->verticalThrottleSpeed + ); + else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*return u[ neighborEntities.template getEntityIndex< 0, 0 >() ];*/ + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::cos( this->xYAngle ) + * std::cos( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->xYAngle ) + * std::cos( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h new file mode 100644 index 000000000..625b74585 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -0,0 +1,838 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsBoilerModel +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsBoilerModelBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsBoilerModelBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsBoilerModel< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsBoilerModelBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for y axis + { + if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } +// if for chimney exit + if( entity.getCoordinates().z() > 0.835 * ( entity.getMesh().getDimensions().z() - 1 ) ) + return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { +// if for z axis + if( + ( + ( entity.getCoordinates().z() < 0.45 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.44 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.43 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.42 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.41 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.40 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.38 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.37 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.36 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + || + ( + ( entity.getCoordinates().z() < 0.35 * ( entity.getMesh().getDimensions().z() - 1 ) ) + && + ( entity.getCoordinates().z() > 0.34 * ( entity.getMesh().getDimensions().z() - 1 ) ) + ) + ) +// if for x axis + { + if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->horizontalThrottleSpeed * ( -1.0 ) + * std::sin( this->zAngle ) + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + if( + ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) + && + ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) + ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->verticalThrottleSpeed + ); + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setHorizontalThrottleSpeed(const RealType horizontalThrottleSpeed) + { + this->horizontalThrottleSpeed = horizontalThrottleSpeed; + } + + void setVerticalThrottleSpeed(const RealType verticalThrottleSpeed) + { + this->verticalThrottleSpeed = verticalThrottleSpeed; + } + + void setZAngle(const RealType zAngle) + { + this->zAngle = zAngle; + } + + void setXYAngle(const RealType xYAngle) + { + this->xYAngle = xYAngle; + } + + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType horizontalThrottleSpeed; + RealType verticalThrottleSpeed; + RealType gamma; + MeshFunctionPointer pressure; + RealType zAngle; + RealType xYAngle; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsBoilerModel< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary Conditions: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h new file mode 100644 index 000000000..9c3c0b099 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/BoundaryConditionsCavity.h @@ -0,0 +1,153 @@ +#include + +#include "DensityBoundaryConditionCavity.h" +#include "MomentumXBoundaryConditionCavity.h" +#include "MomentumYBoundaryConditionCavity.h" +#include "MomentumZBoundaryConditionCavity.h" +#include "EnergyBoundaryConditionCavity.h" + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class BoundaryConditionsCavity +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DensityBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::MomentumXBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::MomentumYBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::MomentumZBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::EnergyBoundaryConditionsCavity< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->densityBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumXBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumYBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->momentumZBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + this->energyBoundaryConditionsPointer->setup( meshPointer, parameters, prefix); + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->densityBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumXBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumYBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->momentumZBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + this->energyBoundaryConditionsPointer->setCompressibleConservativeVariables(compressibleConservativeVariables); + } + + void setTimestep(const RealType timestep) + { + this->densityBoundaryConditionsPointer->setTimestep(timestep); + this->momentumXBoundaryConditionsPointer->setTimestep(timestep); + this->momentumYBoundaryConditionsPointer->setTimestep(timestep); + this->momentumZBoundaryConditionsPointer->setTimestep(timestep); + this->energyBoundaryConditionsPointer->setTimestep(timestep); + } + + void setGamma(const RealType gamma) + { + this->densityBoundaryConditionsPointer->setGamma(gamma); + this->momentumXBoundaryConditionsPointer->setGamma(gamma); + this->momentumYBoundaryConditionsPointer->setGamma(gamma); + this->momentumZBoundaryConditionsPointer->setGamma(gamma); + this->energyBoundaryConditionsPointer->setGamma(gamma); + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->densityBoundaryConditionsPointer->setPressure(pressure); + this->momentumXBoundaryConditionsPointer->setPressure(pressure); + this->momentumYBoundaryConditionsPointer->setPressure(pressure); + this->momentumZBoundaryConditionsPointer->setPressure(pressure); + this->energyBoundaryConditionsPointer->setPressure(pressure); + } + + void setSpeed(const RealType cavitySpeed) + { + this->momentumXBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumYBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->momentumZBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + this->energyBoundaryConditionsPointer->setCavitySpeed(cavitySpeed); + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h new file mode 100644 index 000000000..c753d324a --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/DensityBoundaryConditionCavity.h @@ -0,0 +1,536 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class DensityBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class DensityBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return u[ neighborEntities.template getEntityIndex< 0 >() ]; + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 1, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -1, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 1 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class DensityBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public DensityBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef DensityBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef DensityBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType gamma; + MeshFunctionPointer pressure; + +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const DensityBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h new file mode 100644 index 000000000..ca5d85442 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/EnergyBoundaryConditionCavity.h @@ -0,0 +1,672 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class EnergyBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function> +class EnergyBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< 1, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + * + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + + 0 + ) + ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< -1, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + + 0 + ) + ); + } + if( entity.getCoordinates().y() == 0 ) + { + return //u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 1 >() ] + / ( this->gamma - 1 ) + ) + + 0 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + + 0 + ) + ); + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, -1 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + * ( + this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + * + this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + + 0 + ) + ); + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class EnergyBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public EnergyBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef EnergyBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef EnergyBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return ( (* this->pressure)[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ] + / ( this->gamma - 1 ) + ) + + 0.5 + * (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + * + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + + + ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 2 ])[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + + 0 + ) + ); + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const EnergyBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h new file mode 100644 index 000000000..07abfdbeb --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumXBoundaryConditionCavity.h @@ -0,0 +1,570 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumXBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumXBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, 1 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 1 >()] + );*/ + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, -1 >()] + * ( + ( this->cavitySpeed/* + * ( + entity.getMesh().getDimensions().x() / 2 - std::abs( (entity.getCoordinates().x() - entity.getMesh().getDimensions().x() / 2 ) ) + ) + / ( entity.getMesh().getDimensions().x() / 2 )*/ + ) + ); + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumXBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumXBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumXBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumXBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] + * ( + this->cavitySpeed + ); + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumXBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h new file mode 100644 index 000000000..a83dd653f --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumYBoundaryConditionCavity.h @@ -0,0 +1,564 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumYBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumYBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< 1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 1, 0 >()] + );*/ + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + /*(* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] + * ( + (* (* this->compressibleConservativeVariables->getMomentum())[ 1 ])[neighborEntities.template getEntityIndex< -1, 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< -1, 0 >()] + );*/ + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumYBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumYBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumYBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumYBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumYBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h new file mode 100644 index 000000000..5fe6f22e5 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Cavity/MomentumZBoundaryConditionCavity.h @@ -0,0 +1,554 @@ +/*************************************************************************** + IdentityOperator.h - description + ------------------- + begin : Nov 17, 2014 + copyright : (C) 2014 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include + +namespace TNL { +namespace Operators { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class MomentumZBoundaryConditionsCavity +{ + +}; + +/**** + * Base + */ +template< typename Function > +class MomentumZBoundaryConditionsCavityBase +{ + public: + + typedef Function FunctionType; + + static void configSetup( const Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + } + + template< typename MeshPointer > + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return Functions::FunctionAdapter< typename MeshPointer::ObjectType, FunctionType >::setup( this->function, meshPointer, parameters, prefix ); + } + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + Function::configSetup( config, prefix ); + }; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return this->function.setup( parameters, prefix ); + }; + + void setFunction( const FunctionType& function ) + { + this->function = function; + }; + + FunctionType& getFunction() + { + return this->function; + } + + const FunctionType& getFunction() const + { + return this->function; + }; + + protected: + + FunctionType function; + +}; + +/**** + * 1D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 1, 1, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 1, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0 >()] + / (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0 >()] + + this->timestep + ); + else + return u[ neighborEntities.template getEntityIndex< -1 >() ]; + + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + else + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 2D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 2, 2, + Real, + Index > + +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 2, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< -0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; + } + } + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +/**** + * 3D grid + */ +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Function, + typename Real, + typename Index > +class MomentumZBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Function, Real, Index > + : public MomentumZBoundaryConditionsCavityBase< Function >, + public Operator< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, + Functions::MeshBoundaryDomain, + 3, 3, + Real, + Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + typedef Function FunctionType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Containers::Vector< RealType, DeviceType, IndexType> DofVectorType; + typedef Containers::StaticVector< 3, RealType > PointType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef MomentumZBoundaryConditionsCavity< MeshType, Function, Real, Index > ThisType; + typedef MomentumZBoundaryConditionsCavityBase< Function > BaseType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + template< typename EntityType, + typename MeshFunction > + __cuda_callable__ + const RealType operator()( const MeshFunction& u, + const EntityType& entity, + const RealType& time = 0 ) const + { + const MeshType& mesh = entity.getMesh(); + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + if( entity.getCoordinates().x() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + if( entity.getCoordinates().z() == 0 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + // The following line is commented to avoid compiler warning + //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; + } + } + + + template< typename EntityType > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const EntityType& entity ) const + { + return 2; + } + + template< typename PreimageFunction, + typename MeshEntity, + typename Matrix, + typename Vector > + __cuda_callable__ + void setMatrixElements( const PreimageFunction& u, + const MeshEntity& entity, + const RealType& time, + const RealType& tau, + Matrix& matrix, + Vector& b ) const + { + const auto& neighborEntities = entity.getNeighborEntities(); + const IndexType& index = entity.getIndex(); + typename Matrix::MatrixRow matrixRow = matrix.getRow( index ); + if( entity.getCoordinates().x() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 1, 0, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< -1, 0, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().x() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 1, 0 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, -1, 0 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().y() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == 0 ) + { + matrixRow.setElement( 0, index, 1.0 ); + matrixRow.setElement( 1, neighborEntities.template getEntityIndex< 0, 0, 1 >(), -1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) + { + matrixRow.setElement( 0, neighborEntities.template getEntityIndex< 0, 0, -1 >(), -1.0 ); + matrixRow.setElement( 1, index, 1.0 ); + b[ index ] = entity.getMesh().getSpaceSteps().z() * + Functions::FunctionAdapter< MeshType, FunctionType >::getValue( this->function, entity, time ); + } + } + + void setTimestep(const RealType timestep ) + { + this->timestep = timestep; + } + + void setGamma(const RealType gamma ) + { + this->gamma = gamma; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + this->compressibleConservativeVariables = compressibleConservativeVariables; + } + + void setPressure(const MeshFunctionPointer& pressure) + { + this->pressure = pressure; + } + + void setCavitySpeed(const RealType cavitySpeed) + { + this->cavitySpeed = cavitySpeed; + } + + private: + CompressibleConservativeVariablesPointer compressibleConservativeVariables; + RealType timestep; + RealType cavitySpeed; + RealType gamma; + MeshFunctionPointer pressure; +}; + +template< typename Mesh, + typename Function, + typename Real, + typename Index > +std::ostream& operator << ( std::ostream& str, const MomentumZBoundaryConditionsCavity< Mesh, Function, Real, Index >& bc ) +{ + str << "Neumann boundary ConditionsCavity: function = " << bc.getFunction(); + return str; +} + +} // namespace Operators +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h new file mode 100644 index 000000000..930183476 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h @@ -0,0 +1,128 @@ +#include +#include +#include +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Function = Functions::Analytic::Constant< Mesh::getMeshDimension(), typename Mesh::RealType >, + int MeshEntitiesDimension = Mesh::getMeshDimension(), + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class BoundaryConditionsDirichlet +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::DirichletBoundaryConditions< MeshType, FunctionType, MeshType::getMeshDimension(), RealType, IndexType > EnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + + } + + void setTimestep(const RealType timestep) + { + + } + + void setGamma(const RealType gamma) + { + + } + + void setPressure(const MeshFunctionPointer& pressure) + { + + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h new file mode 100644 index 000000000..ec99b86e7 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/Neumann/BoundaryConditionsNeumann.h @@ -0,0 +1,124 @@ +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Function, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::GlobalIndexType > +class BoundaryConditionsNeumann +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef Index IndexType; + typedef Function FunctionType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef typename Mesh::DeviceType DeviceType; + + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > DensityBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumXBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumYBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > MomentumZBoundaryConditionsType; + typedef TNL::Operators::NeumannBoundaryConditions< MeshType, FunctionType, RealType, IndexType > EnergyBoundaryConditionsType; + typedef CompressibleConservativeVariables< MeshType > CompressibleConservativeVariablesType; + + typedef Pointers::SharedPointer< DensityBoundaryConditionsType > DensityBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumXBoundaryConditionsType > MomentumXBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumYBoundaryConditionsType > MomentumYBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< MomentumZBoundaryConditionsType > MomentumZBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< EnergyBoundaryConditionsType > EnergyBoundaryConditionsTypePointer; + typedef Pointers::SharedPointer< CompressibleConservativeVariablesType > CompressibleConservativeVariablesPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + } + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + void setCompressibleConservativeVariables(const CompressibleConservativeVariablesPointer& compressibleConservativeVariables) + { + + } + + void setTimestep(const RealType timestep) + { + + } + + void setGamma(const RealType gamma) + { + + } + + void setPressure(const MeshFunctionPointer& pressure) + { + + } + + void setSpeed(const RealType cavitySpeed) + { + + } + + void setHorizontalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + void setVerticalThrottleSpeed(const RealType startSpeed, + const RealType finalSpeed, + const RealType time, + const RealType finalTime ) + { + + } + + DensityBoundaryConditionsTypePointer& getDensityBoundaryCondition() + { + return this->densityBoundaryConditionsPointer; + } + + MomentumXBoundaryConditionsTypePointer& getMomentumXBoundaryCondition() + { + return this->momentumXBoundaryConditionsPointer; + } + + MomentumYBoundaryConditionsTypePointer& getMomentumYBoundaryCondition() + { + return this->momentumYBoundaryConditionsPointer; + } + + MomentumZBoundaryConditionsTypePointer& getMomentumZBoundaryCondition() + { + return this->momentumZBoundaryConditionsPointer; + } + + EnergyBoundaryConditionsTypePointer& getEnergyBoundaryCondition() + { + return this->energyBoundaryConditionsPointer; + } + + + protected: + DensityBoundaryConditionsTypePointer densityBoundaryConditionsPointer; + MomentumXBoundaryConditionsTypePointer momentumXBoundaryConditionsPointer; + MomentumYBoundaryConditionsTypePointer momentumYBoundaryConditionsPointer; + MomentumZBoundaryConditionsTypePointer momentumZBoundaryConditionsPointer; + EnergyBoundaryConditionsTypePointer energyBoundaryConditionsPointer; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/CMakeLists.txt b/src/Examples/turbulent-flows/zero-equation-model/CMakeLists.txt new file mode 100644 index 000000000..1801a61e4 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/CMakeLists.txt @@ -0,0 +1,101 @@ +#zero-equation-turbulence-model-Lax-Friedrichs + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + zeroEquationTurbulenceModelLaxFriedrichs.cpp + zeroEquationTurbulenceModelLaxFriedrichs.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-zero-equation-turbulence-model-Lax-Friedrichs zeroEquationTurbulenceModelLaxFriedrichs.cu) + target_link_libraries (tnl-zero-equation-turbulence-model-Lax-Friedrichs ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-zero-equation-turbulence-model-Lax-Friedrichs zeroEquationTurbulenceModelLaxFriedrichs.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-zero-equation-turbulence-model-Lax-Friedrichs + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-zero-equation-turbulence-model-Lax-Friedrichs + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#zero-equation-turbulence-model-Steger-Warming + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + zeroEquationTurbulenceModelStegerWarming.cpp + zeroEquationTurbulenceModelStegerWarming.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-zero-equation-turbulence-model-Steger-Warming zeroEquationTurbulenceModelStegerWarming.cu) + target_link_libraries (tnl-zero-equation-turbulence-model-Steger-Warming ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-zero-equation-turbulence-model-Steger-Warming zeroEquationTurbulenceModelStegerWarming.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-zero-equation-turbulence-model-Steger-Warming + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-zero-equation-turbulence-model-Steger-Warming + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#zero-equation-turbulence-model-Van-Leer + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + zeroEquationTurbulenceModelVanLeer.cpp + zeroEquationTurbulenceModelVanLeer.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-zero-equation-turbulence-model-Van-Leer zeroEquationTurbulenceModelVanLeer.cu) + target_link_libraries (tnl-zero-equation-turbulence-model-Van-Leer ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-zero-equation-turbulence-model-Van-Leer zeroEquationTurbulenceModelVanLeer.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-zero-equation-turbulence-model-Van-Leer + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-zero-equation-turbulence-model-Van-Leer + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#zero-equation-turbulence-model-AUSM-plus + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + zeroEquationTurbulenceModelAUSMPlus.cpp + zeroEquationTurbulenceModelAUSMPlus.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-zero-equation-turbulence-model-AUSM-plus zeroEquationTurbulenceModelAUSMPlus.cu) + target_link_libraries (tnl-zero-equation-turbulence-model-AUSM-plus ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-zero-equation-turbulence-model-AUSM-plus zeroEquationTurbulenceModelAUSMPlus.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-zero-equation-turbulence-model-AUSM-plus + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-zero-equation-turbulence-model-AUSM-plus + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/zero-equation-model/CMakeLists_separate.txt b/src/Examples/turbulent-flows/zero-equation-model/CMakeLists_separate.txt new file mode 100644 index 000000000..cd8e6f870 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/CMakeLists_separate.txt @@ -0,0 +1,101 @@ +#navier-stokes-Lax-Friedrichs + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesLaxFriedrichs.cpp + navierStokesLaxFriedrichs.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cu) + target_link_libraries (tnl-navier-stokes-Lax-Friedrichs ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Lax-Friedrichs navierStokesLaxFriedrichs.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Lax-Friedrichs + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Lax-Friedrichs + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Steger-Warming + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesStegerWarming.cpp + navierStokesStegerWarming.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cu) + target_link_libraries (tnl-navier-stokes-Steger-Warming ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Steger-Warming navierStokesStegerWarming.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Steger-Warming + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Steger-Warming + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-Van-Leer + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesVanLeer.cpp + navierStokesVanLeer.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cu) + target_link_libraries (tnl-navier-stokes-Van-Leer ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-Van-Leer navierStokesVanLeer.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-Van-Leer + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-Van-Leer + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + +#navier-stokes-AUSM-plus + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokesAUSMPlus.cpp + navierStokesAUSMPlus.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cu) + target_link_libraries (tnl-navier-stokes-AUSM-plus ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes-AUSM-plus navierStokesAUSMPlus.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes-AUSM-plus + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes-AUSM-plus + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/zero-equation-model/CMakeLists_together.txt b/src/Examples/turbulent-flows/zero-equation-model/CMakeLists_together.txt new file mode 100644 index 000000000..f26fc6d34 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/CMakeLists_together.txt @@ -0,0 +1,26 @@ +#navier-stokes + +set( tnl_flow_HEADERS + CompressibleConservativeVariables.h ) + +set( tnl_flow_SOURCES + navierStokes.cpp + navierStokes.cu ) + +IF( BUILD_CUDA ) + CUDA_ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cu) + target_link_libraries (tnl-navier-stokes ${CUSPARSE_LIBRARY} ) +ELSE( BUILD_CUDA ) + ADD_EXECUTABLE(tnl-navier-stokes navierStokes.cpp) +ENDIF( BUILD_CUDA ) + + +INSTALL( TARGETS tnl-navier-stokes + RUNTIME DESTINATION bin + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) + +INSTALL( FILES run-navier-stokes + ${tnl_flow_SOURCES} + DESTINATION ${TNL_TARGET_DATA_DIRECTORY}/examples/flow ) + + diff --git a/src/Examples/turbulent-flows/zero-equation-model/CompressibleConservativeVariables.h b/src/Examples/turbulent-flows/zero-equation-model/CompressibleConservativeVariables.h new file mode 100644 index 000000000..b66f4d5c5 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/CompressibleConservativeVariables.h @@ -0,0 +1,156 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +namespace TNL { + +template< typename Mesh > +class CompressibleConservativeVariables +{ + public: + typedef Mesh MeshType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > MomentumFieldPointer; + + CompressibleConservativeVariables(){}; + + CompressibleConservativeVariables( const MeshPointer& meshPointer ) + : density( meshPointer ), + momentum( meshPointer ), + //pressure( meshPointer ), + energy( meshPointer ){}; + + void setMesh( const MeshPointer& meshPointer ) + { + this->density->setMesh( meshPointer ); + this->momentum->setMesh( meshPointer ); + //this->pressure.setMesh( meshPointer ); + this->energy->setMesh( meshPointer ); + } + + template< typename Vector > + void bind( const MeshPointer& meshPointer, + const Vector& data, + IndexType offset = 0 ) + { + IndexType currentOffset( offset ); + this->density->bind( meshPointer, data, currentOffset ); + currentOffset += this->density->getDofs( meshPointer ); + for( IndexType i = 0; i < Dimensions; i++ ) + { + ( *this->momentum )[ i ]->bind( meshPointer, data, currentOffset ); + currentOffset += ( *this->momentum )[ i ]->getDofs( meshPointer ); + } + this->energy->bind( meshPointer, data, currentOffset ); + } + + IndexType getDofs( const MeshPointer& meshPointer ) const + { + return this->density->getDofs( meshPointer ) + + this->momentum->getDofs( meshPointer ) + + this->energy->getDofs( meshPointer ); + } + + __cuda_callable__ + MeshFunctionPointer& getDensity() + { + return this->density; + } + + __cuda_callable__ + const MeshFunctionPointer& getDensity() const + { + return this->density; + } + + void setDensity( MeshFunctionPointer& density ) + { + this->density = density; + } + + __cuda_callable__ + MomentumFieldPointer& getMomentum() + { + return this->momentum; + } + + __cuda_callable__ + const MomentumFieldPointer& getMomentum() const + { + return this->momentum; + } + + void setMomentum( MomentumFieldPointer& momentum ) + { + this->momentum = momentum; + } + + /* + __cuda_callable__ + MeshFunctionPointer& getPressure() + { + return this->pressure; + } + + __cuda_callable__ + const MeshFunctionPointer& getPressure() const + { + return this->pressure; + } + + void setPressure( MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }*/ + + __cuda_callable__ + MeshFunctionPointer& getEnergy() + { + return this->energy; + } + + __cuda_callable__ + const MeshFunctionPointer& getEnergy() const + { + return this->energy; + } + + void setEnergy( MeshFunctionPointer& energy ) + { + this->energy = energy; + } + + void getVelocityField( VelocityFieldType& velocityField ) + { + + } + + protected: + + MeshFunctionPointer density; + MomentumFieldPointer momentum; + MeshFunctionPointer energy; + +}; + +} // namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h new file mode 100644 index 000000000..0ef0575f2 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h @@ -0,0 +1,185 @@ +/*************************************************************************** + AUSMPlus.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "AUSMPlusContinuity.h" +#include "AUSMPlusEnergy.h" +#include "AUSMPlusMomentumX.h" +#include "AUSMPlusMomentumY.h" +#include "AUSMPlusMomentumZ.h" + +#include "Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = PrandtlOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlus +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + + typedef AUSMPlusContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef AUSMPlusMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef AUSMPlusMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef AUSMPlusMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef AUSMPlusEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + + typedef Pointers::SharedPointer< OperatorRightHandSide > OperatorRightHandSidePointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + AUSMPlus() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "AUSMPlus" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const OperatorRightHandSidePointer& getOperatorRightHandSide() const + { + return this->operatorRightHandSidePointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + + OperatorRightHandSidePointer operatorRightHandSidePointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h new file mode 100644 index 000000000..2d92e9dc8 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h @@ -0,0 +1,401 @@ +/*************************************************************************** + AUSMPlusContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "AUSMPlusContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType DensityFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity + MachBorderMinus * RightDensity ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return hxInverse * ( + this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return hxInverse * ( + this->DensityFlux( u[ west ], u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->DensityFlux( u[ north ], u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) + - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return hxInverse * ( + this->DensityFlux( u[ west ] , u[ center ], velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->DensityFlux( u[ north ] , u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) + - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + ) + + hzInverse * ( + this->DensityFlux( u[ up ] , u[ center ], velocity_z_up , velocity_z_center, pressure_up , pressure_center ) + - this->DensityFlux( u[ center ], u[ down ] , velocity_z_center, velocity_z_down , pressure_center, pressure_down ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h new file mode 100644 index 000000000..a0f4c7ea9 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h @@ -0,0 +1,516 @@ +/*************************************************************************** + AUSMPlusEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + AUSMPlusEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "AUSMPlusEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + RealType EnergyFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure, + const RealType& LeftEnergy, + const RealType& RightEnergy ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * ( LeftEnergy + LeftPressure) + MachBorderMinus * ( RightEnergy + RightPressure ) ); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->EnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->EnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->EnergyFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center, u[ west ], u[ center ] ) + - this->EnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) + ) + + hyInverse * ( + this->EnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->EnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) + ) + + hzInverse * ( + this->EnergyFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ], u[ center ] ) + - this->EnergyFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h new file mode 100644 index 000000000..2cbf6ad16 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h @@ -0,0 +1,200 @@ +/*************************************************************************** + AUSMPlusMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + RealType MainMomentumFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + RealType PressureSplitingPlus = 0; + RealType PressureSplitingMinus = 0; + RealType PressureBorder = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + PressureSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + PressureSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) * (2.0 - LeftMachNumber ) + + 3.0 / 16.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + PressureSplitingPlus = 1.0; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + PressureSplitingMinus = 1.0; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) * (2.0 + RightMachNumber ) + - 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + PressureSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + PressureBorder = PressureSplitingPlus * LeftPressure + PressureSplitingMinus * RightPressure; + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity * LeftVelocity + MachBorderMinus * RightDensity * RightVelocity ) + PressureBorder; + } + + RealType OtherMomentumFlux( const RealType& LeftDensity, + const RealType& RightDensity, + const RealType& LeftVelocity, + const RealType& RightVelocity, + const RealType& LeftOtherVelocity, + const RealType& RightOtherVelocity, + const RealType& LeftPressure, + const RealType& RightPressure ) const + { + const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); + const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); + const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; + const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; + RealType MachSplitingPlus = 0; + RealType MachSplitingMinus = 0; + RealType MachBorderPlus = 0; + RealType MachBorderMinus = 0; + if ( LeftMachNumber <= -1.0 ) + { + MachSplitingPlus = 0; + } + else if ( LeftMachNumber <= 1.0 ) + { + MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); + } + else + { + MachSplitingPlus = LeftMachNumber; + } + if ( RightMachNumber <= -1.0 ) + { + MachSplitingMinus = RightMachNumber; + } + else if ( RightMachNumber <= 1.0 ) + { + MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); + } + else + { + MachSplitingMinus = 0; + } + MachBorderPlus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) + std::abs( MachSplitingPlus + MachSplitingMinus )); + MachBorderMinus = 0.5 * ( ( MachSplitingPlus + MachSplitingMinus ) - std::abs( MachSplitingPlus + MachSplitingMinus )); + return BorderSpeedOfSound * ( MachBorderPlus * LeftDensity * LeftOtherVelocity + MachBorderMinus * RightDensity * RightOtherVelocity ); + } + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType dynamicalViscosity; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h new file mode 100644 index 000000000..1468cf891 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h @@ -0,0 +1,398 @@ +/*************************************************************************** + AUSMPlusMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->MainMomentumFlux( density_west , density_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->MainMomentumFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->OtherMomentumFlux( density_down , density_center, velocity_x_down , velocity_x_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->OtherMomentumFlux( density_center, density_up , velocity_x_center, velocity_x_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h new file mode 100644 index 000000000..d1a8d4304 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumY.h @@ -0,0 +1,371 @@ +/*************************************************************************** + AUSMPlusMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_y_west , velocity_y_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_y_center, velocity_y_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->MainMomentumFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->MainMomentumFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->OtherMomentumFlux( density_down , density_center, velocity_y_down , velocity_y_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->OtherMomentumFlux( density_center, density_up , velocity_y_center, velocity_y_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h new file mode 100644 index 000000000..fcc6183f2 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h @@ -0,0 +1,316 @@ +/*************************************************************************** + AUSMPlusMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "AUSMPlusMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class AUSMPlusMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class AUSMPlusMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public AUSMPlusMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef AUSMPlusMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "AUSMPlusMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return hxInverse * ( + this->OtherMomentumFlux( density_west , density_center, velocity_z_west , velocity_z_center, velocity_x_west , velocity_x_center, pressure_west , pressure_center ) + - this->OtherMomentumFlux( density_center, density_east , velocity_z_center, velocity_z_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) + ) + + hyInverse * ( + this->OtherMomentumFlux( density_south , density_center, velocity_z_south , velocity_z_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + ) + + hzInverse * ( + this->MainMomentumFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->MainMomentumFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h new file mode 100644 index 000000000..4be9de0ef --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h @@ -0,0 +1,183 @@ +/*************************************************************************** + LaxFridrichs.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "LaxFridrichsContinuity.h" +#include "LaxFridrichsEnergy.h" +#include "LaxFridrichsMomentumX.h" +#include "LaxFridrichsMomentumY.h" +#include "LaxFridrichsMomentumZ.h" + +#include "Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = PrandtlOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichs +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + + typedef LaxFridrichsContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef LaxFridrichsMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef LaxFridrichsMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef LaxFridrichsMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef LaxFridrichsEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + + typedef Pointers::SharedPointer< OperatorRightHandSide > OperatorRightHandSidePointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "numerical-viscosity", "Value of artificial (numerical) viscosity in the Lax-Fridrichs scheme", 1.0 ); + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + LaxFridrichs() + : artificialViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "Lax-Friedrichs" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->artificialViscosity = parameters.getParameter< double >( prefix + "numerical-viscosity" ); + this->continuityOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumXOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumYOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->momentumZOperatorPointer->setArtificialViscosity( artificialViscosity ); + this->energyOperatorPointer->setArtificialViscosity( artificialViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const OperatorRightHandSidePointer& getOperatorRightHandSide() const + { + return this->operatorRightHandSidePointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + + OperatorRightHandSidePointer operatorRightHandSidePointer; + + RealType artificialViscosity; + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h new file mode 100644 index 000000000..e82c9d424 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsContinuity.h @@ -0,0 +1,310 @@ +/*************************************************************************** + LaxFridrichsContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsContinuityBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + RealType artificialViscosity; +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + +// return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) +// - 0.5 * ( u[ west ] * velocity_x_west - u[ east ] * velocity_x_east ) * hxInverse; + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( u[ west ] - 2.0 * u[ center ] + u[ east ] ) + - 0.5 * ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( u[ west ] + u[ east ] + u[ south ] + u[ north ] - 4.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( u[ west ] + u[ east ] + u[ south ] + u[ north ] + u[ up ] + u[ down ]- 6.0 * u[ center ] ) + - 0.5 * ( ( u[ east ] * velocity_x_east - u[ west ] * velocity_x_west ) * hxInverse + + ( u[ north ] * velocity_y_north - u[ south ] * velocity_y_south ) * hyInverse + + ( u[ up ] * velocity_z_up - u[ down ] * velocity_z_down ) * hzInverse ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h new file mode 100644 index 000000000..18ef0ed4a --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -0,0 +1,344 @@ +/*************************************************************************** + LaxFridrichsEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( e[ west ] - 2.0 * e[ center ] + e[ east ] ) + - 0.5 * ( ( e[ east ] + pressure_east ) * velocity_x_east + - ( e[ west ] + pressure_west ) * velocity_x_west ) * hxInverse + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( e[ west ] + e[ east ] + e[ south ] + e[ north ] - 4.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse ) + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( e[ west ] + e[ east ] + e[ south ] + e[ north ] + e[ up ] + e[ down ] - 6.0 * e[ center ] ) + - 0.5 * ( ( ( ( e[ east ] + pressure_east ) * velocity_x_east ) + -( ( e[ west ] + pressure_west ) * velocity_x_west ) ) * hxInverse + + ( ( ( e[ north ] + pressure_north ) * velocity_y_north ) + -( ( e[ south ] + pressure_south ) * velocity_y_south ) ) * hyInverse + + ( ( ( e[ up ] + pressure_up ) * velocity_z_up ) + -( ( e[ down ] + pressure_down ) * velocity_z_down ) ) * hzInverse ) + + + this->rightHandSide(e, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h new file mode 100644 index 000000000..6ed4935f5 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -0,0 +1,83 @@ +/*************************************************************************** + LaxFridrichsMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + LaxFridrichsMomentumBase() + : artificialViscosity( 1.0 ){}; + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + protected: + + RealType tau; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h new file mode 100644 index 000000000..57258d1a5 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumX.h @@ -0,0 +1,295 @@ +/*************************************************************************** + LaxFridrichsMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return 1.0 / ( 2.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] - 2.0 * rho_u[ center ] ) + - 0.5 * ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + -( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] - 4.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) ) * hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) ) * hyInverse ) + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_u[ west ] + rho_u[ east ] + rho_u[ south ] + rho_u[ north ] + rho_u[ up ] + rho_u[ down ] - 6.0 * rho_u[ center ] ) + - 0.5 * ( ( ( rho_u[ east ] * velocity_x_east + pressure_east ) + - ( rho_u[ west ] * velocity_x_west + pressure_west ) )* hxInverse + + ( ( rho_u[ north ] * velocity_y_north ) + - ( rho_u[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_u[ up ] * velocity_z_up ) + - ( rho_u[ down ] * velocity_z_down ) )* hzInverse ) + + + this->rightHandSide(rho_u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h new file mode 100644 index 000000000..4cca02779 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumY.h @@ -0,0 +1,280 @@ +/*************************************************************************** + LaxFridrichsMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + + return 1.0 / ( 4.0 * this->tau ) * this->artificialViscosity * ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] - 4.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) )* hyInverse ) + + + this->rightHandSide(rho_v, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_v[ west ] + rho_v[ east ] + rho_v[ south ] + rho_v[ north ] + rho_v[ up ] + rho_v[ down ] - 6.0 * rho_v[ center ] ) + - 0.5 * ( ( ( rho_v[ east ] * velocity_x_east ) + - ( rho_v[ west ] * velocity_x_west ) ) * hxInverse + + ( ( rho_v[ north ] * velocity_y_north + pressure_north ) + - ( rho_v[ south ] * velocity_y_south + pressure_south ) ) * hyInverse + + ( ( rho_v[ up ] * velocity_z_up ) + - ( rho_v[ down ] * velocity_z_down ) ) * hzInverse ) + + + this->rightHandSide(rho_v, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h new file mode 100644 index 000000000..1f394bfef --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichsMomentumZ.h @@ -0,0 +1,251 @@ +/*************************************************************************** + LaxFridrichsMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "LaxFridrichsMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class LaxFridrichsMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class LaxFridrichsMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public LaxFridrichsMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef LaxFridrichsMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 1.0 / ( 6.0 * this->tau ) * this->artificialViscosity * + ( rho_w[ west ] + rho_w[ east ] + rho_w[ south ] + rho_w[ north ] + rho_w[ up ] + rho_w[ down ] - 6.0 * rho_w[ center ] ) + -0.5 * ( ( ( rho_w[ east ] * velocity_x_east ) + - ( rho_w[ west ] * velocity_x_west ) )* hxInverse + + ( ( rho_w[ north ] * velocity_y_north ) + - ( rho_w[ south ] * velocity_y_south ) )* hyInverse + + ( ( rho_w[ up ] * velocity_z_up + pressure_up ) + - ( rho_w[ down ] * velocity_z_down + pressure_down ) )* hzInverse ) + + + this->rightHandSide(rho_w, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h new file mode 100644 index 000000000..c00deb195 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h @@ -0,0 +1,176 @@ +/*************************************************************************** + StegerWarming.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "StegerWarmingContinuity.h" +#include "StegerWarmingEnergy.h" +#include "StegerWarmingMomentumX.h" +#include "StegerWarmingMomentumY.h" +#include "StegerWarmingMomentumZ.h" + +#include "Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = PrandtlOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarming +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + + typedef StegerWarmingContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef StegerWarmingMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef StegerWarmingMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef StegerWarmingMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef StegerWarmingEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + StegerWarming() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "Steger-Warming"<< std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h new file mode 100644 index 000000000..a27d3e139 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingContinuity.h @@ -0,0 +1,396 @@ +/*************************************************************************** + StegerWarmingContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) +/* -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + )*/ + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h new file mode 100644 index 000000000..81037b5db --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingEnergy.h @@ -0,0 +1,555 @@ +/*************************************************************************** + StegerWarmingEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "StegerWarmingEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + } + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + + ( machNumber * ( machNumber + 1.0 ) ) + + ( ( machNumber + 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound * speedOfSound / ( 2.0 * this->gamma ) + * ( + ( ( machNumber - 1.0 ) * 0.5 * ( machNumber * machNumber + ( velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) / ( speedOfSound * speedOfSound ) ) ) + - ( machNumber * ( machNumber - 1.0 ) ) + + ( ( machNumber - 1.0 ) / ( this->gamma - 1.0 ) ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hzInverse * ( + this->positiveEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_z_down , velocity_x_down , velocity_y_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_z_up , velocity_x_up , velocity_y_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h new file mode 100644 index 000000000..ce0a7125b --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumBase.h @@ -0,0 +1,145 @@ +/*************************************************************************** + StegerWarmingMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber + 1.0 ) * ( machNumber + 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber + 1.0 ) * (machNumber + 1.0 ) ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 0.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( 2.0 * ( this->gamma - 1.0 ) * machNumber * machNumber + (machNumber - 1.0 ) * (machNumber - 1.0 ) ); + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( ( machNumber - 1.0 ) * ( machNumber - 1.0 ) ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 0.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( ( 2.0 * this->gamma - 1.0 ) * machNumber - 1.0 ) * velocity_other; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h new file mode 100644 index 000000000..c6588083c --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumX.h @@ -0,0 +1,356 @@ +/*************************************************************************** + StegerWarmingMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h new file mode 100644 index 000000000..210fb6087 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumY.h @@ -0,0 +1,326 @@ +/*************************************************************************** + StegerWarmingMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h new file mode 100644 index 000000000..135352d2f --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarmingMomentumZ.h @@ -0,0 +1,282 @@ +/*************************************************************************** + StegerWarmingMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "StegerWarmingMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class StegerWarmingMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class StegerWarmingMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public StegerWarmingMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef StegerWarmingMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "StegerWarmingMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return 0-hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h new file mode 100644 index 000000000..e413c4b10 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h @@ -0,0 +1,185 @@ +/*************************************************************************** + VanLeer.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "VanLeerContinuity.h" +#include "VanLeerEnergy.h" +#include "VanLeerMomentumX.h" +#include "VanLeerMomentumY.h" +#include "VanLeerMomentumZ.h" + +#include "Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide = PrandtlOperatorRightHandSide < Mesh, typename Mesh::RealType, typename Mesh::IndexType >, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeer +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef typename OperatorRightHandSide::ContinuityOperatorRightHandSideType ContinuityOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumXOperatorRightHandSideType MomentumXOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumYOperatorRightHandSideType MomentumYOperatorRightHandSideType; + typedef typename OperatorRightHandSide::MomentumZOperatorRightHandSideType MomentumZOperatorRightHandSideType; + typedef typename OperatorRightHandSide::EnergyOperatorRightHandSideType EnergyOperatorRightHandSideType; + + typedef VanLeerContinuity< Mesh, ContinuityOperatorRightHandSideType, Real, Index > ContinuityOperatorType; + typedef VanLeerMomentumX< Mesh, MomentumXOperatorRightHandSideType, Real, Index > MomentumXOperatorType; + typedef VanLeerMomentumY< Mesh, MomentumYOperatorRightHandSideType, Real, Index > MomentumYOperatorType; + typedef VanLeerMomentumZ< Mesh, MomentumZOperatorRightHandSideType, Real, Index > MomentumZOperatorType; + typedef VanLeerEnergy< Mesh, EnergyOperatorRightHandSideType, Real, Index > EnergyOperatorType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorType > ContinuityOperatorPointer; + typedef Pointers::SharedPointer< MomentumXOperatorType > MomentumXOperatorPointer; + typedef Pointers::SharedPointer< MomentumYOperatorType > MomentumYOperatorPointer; + typedef Pointers::SharedPointer< MomentumZOperatorType > MomentumZOperatorPointer; + typedef Pointers::SharedPointer< EnergyOperatorType > EnergyOperatorPointer; + + typedef Pointers::SharedPointer< OperatorRightHandSide > OperatorRightHandSidePointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + VanLeer() + :dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + std::cout << "VanLeer" << std::endl; + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorPointer->setDynamicalViscosity( dynamicalViscosity ); + + return true; + } + + void setTau( const RealType& tau ) + { + this->continuityOperatorPointer->setTau( tau ); + this->momentumXOperatorPointer->setTau( tau ); + this->momentumYOperatorPointer->setTau( tau ); + this->momentumZOperatorPointer->setTau( tau ); + this->energyOperatorPointer->setTau( tau ); + } + + void setGamma( const RealType& gamma ) + { + this->continuityOperatorPointer->setGamma( gamma ); + this->momentumXOperatorPointer->setGamma( gamma ); + this->momentumYOperatorPointer->setGamma( gamma ); + this->momentumZOperatorPointer->setGamma( gamma ); + this->energyOperatorPointer->setGamma( gamma ); + } + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->continuityOperatorPointer->setPressure( pressure ); + this->momentumXOperatorPointer->setPressure( pressure ); + this->momentumYOperatorPointer->setPressure( pressure ); + this->momentumZOperatorPointer->setPressure( pressure ); + this->energyOperatorPointer->setPressure( pressure ); + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorPointer->setVelocity( velocity ); + this->momentumXOperatorPointer->setVelocity( velocity ); + this->momentumYOperatorPointer->setVelocity( velocity ); + this->momentumZOperatorPointer->setVelocity( velocity ); + this->energyOperatorPointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorPointer->setTurbulentViscosity( turbulentViscosity ); + } + + const ContinuityOperatorPointer& getContinuityOperator() const + { + return this->continuityOperatorPointer; + } + + const MomentumXOperatorPointer& getMomentumXOperator() const + { + return this->momentumXOperatorPointer; + } + + const MomentumYOperatorPointer& getMomentumYOperator() const + { + return this->momentumYOperatorPointer; + } + + const MomentumZOperatorPointer& getMomentumZOperator() const + { + return this->momentumZOperatorPointer; + } + + const EnergyOperatorPointer& getEnergyOperator() const + { + return this->energyOperatorPointer; + } + + const OperatorRightHandSidePointer& getOperatorRightHandSide() const + { + return this->operatorRightHandSidePointer; + } + + protected: + + ContinuityOperatorPointer continuityOperatorPointer; + MomentumXOperatorPointer momentumXOperatorPointer; + MomentumYOperatorPointer momentumYOperatorPointer; + MomentumZOperatorPointer momentumZOperatorPointer; + EnergyOperatorPointer energyOperatorPointer; + + OperatorRightHandSidePointer operatorRightHandSidePointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h new file mode 100644 index 000000000..3b497125a --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerContinuity.h @@ -0,0 +1,396 @@ +/*************************************************************************** + VanLeerContinuity.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuityBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + static String getType() + { + return String( "VanLeerContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + RealType positiveDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ); + else + return density * velocity; + }; + + RealType negativeDensityFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ); + else + return 0.0; + }; + + RealType multiply (const RealType& a, const RealType& b ) const + { + return a * b; + }; + + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + +}; + + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerContinuity +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerContinuityBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerContinuityBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + //rho + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + + return -hxInverse * ( + this->positiveDensityFlux( u[ center ], velocity_x_center, pressure_center ) + - this->positiveDensityFlux( u[ west ], velocity_x_west , pressure_west ) + - this->negativeDensityFlux( u[ center ], velocity_x_center, pressure_center ) + + this->negativeDensityFlux( u[ east ], velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveDensityFlux( u[ center ], velocity_y_center, pressure_center ) + - this->positiveDensityFlux( u[ south ], velocity_y_south , pressure_south ) + - this->negativeDensityFlux( u[ center ], velocity_y_center, pressure_center ) + + this->negativeDensityFlux( u[ north ], velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveDensityFlux( u[ center ], velocity_z_center, pressure_center ) + - this->positiveDensityFlux( u[ down ], velocity_z_down , pressure_down ) + - this->negativeDensityFlux( u[ center ], velocity_z_center, pressure_center ) + + this->negativeDensityFlux( u[ up ], velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h new file mode 100644 index 000000000..9805faddb --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerEnergy.h @@ -0,0 +1,587 @@ +/*************************************************************************** + VanLeerEnergy.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergyBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + VanLeerEnergyBase() + : artificialViscosity( 1.0 ){}; + + static String getType() + { + return String( "VanLeerEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setArtificialViscosity( const RealType& artificialViscosity ) + { + this->artificialViscosity = artificialViscosity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType artificialViscosity, dynamicalViscosity; + + MeshFunctionPointer density; +}; + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerEnergy +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerEnergyBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerEnergyBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + RealType positiveEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + }; + + RealType negativeEnergyFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other1, const RealType& velocity_other2, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return velocity_main * ( pressure + pressure / ( this->gamma - 1.0 ) + 0.5 * density * ( velocity_main * velocity_main + velocity_other1 * velocity_other1 + velocity_other2 * velocity_other2 ) ); + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4.0 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) + * ( + velocity_other1 * velocity_other1 / 2.0 + + velocity_other2 * velocity_other2 / 2.0 + + 2.0 * speedOfSound * speedOfSound / ( this->gamma * this->gamma - 1.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + * ( 1.0 - ( this->gamma - 1.0 ) * machNumber / 2.0 ) + ); + else + return 0.0; + }; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_west , velocity_x_west , velocity_y_west , velocity_z_west , pressure_west ) + - this->negativeEnergyFlux( density_center, velocity_x_center, velocity_y_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_east , velocity_x_east , velocity_y_east , velocity_z_east , pressure_east ) + ) + -hyInverse * ( + this->positiveEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + - this->positiveEnergyFlux( density_south , velocity_y_south , velocity_x_south , velocity_z_south , pressure_south ) + - this->negativeEnergyFlux( density_center, velocity_y_center, velocity_x_center, velocity_z_center, pressure_center) + + this->negativeEnergyFlux( density_north , velocity_y_north , velocity_x_north , velocity_z_north , pressure_north ) + ) + -hzInverse * ( + this->positiveEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + - this->positiveEnergyFlux( density_down , velocity_z_down , velocity_x_down , velocity_y_down , pressure_down ) + - this->negativeEnergyFlux( density_center, velocity_z_center, velocity_x_center, velocity_y_center, pressure_center) + + this->negativeEnergyFlux( density_up , velocity_z_up , velocity_x_up , velocity_y_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h new file mode 100644 index 000000000..b1a52af2f --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumBase.h @@ -0,0 +1,140 @@ +/*************************************************************************** + VanLeerMomentumBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef OperatorRightHandSide OperatorRightHandSideType; + + + void setTau(const Real& tau) + { + this->tau = tau; + }; + + void setGamma(const Real& gamma) + { + this->gamma = gamma; + }; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + }; + + void setPressure( const MeshFunctionPointer& pressure ) + { + this->pressure = pressure; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->rightHandSide.setTurbulentViscosity(turbulentViscosity); + }; + + RealType positiveMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return 0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * ( 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return density * velocity * velocity + pressure; + }; + + RealType negativeMainMomentumFlux( const RealType& density, const RealType& velocity, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity * velocity + pressure; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound * speedOfSound / ( 2 * this->gamma ) * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * ( - 1.0 + ( this->gamma - 1.0 ) * machNumber / 2.0 ); + else + return 0; + }; + + RealType positiveOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return 0.0; + else if ( machNumber <= 1.0 ) + return density * speedOfSound / 4.0 * ( machNumber + 1.0 ) * ( machNumber + 1.0 ) * velocity_other; + else + return density * velocity_main * velocity_other; + }; + + RealType negativeOtherMomentumFlux( const RealType& density, const RealType& velocity_main, const RealType& velocity_other, const RealType& pressure ) const + { + const RealType& speedOfSound = std::sqrt( this->gamma * pressure / density ); + const RealType& machNumber = velocity_main / speedOfSound; + if ( machNumber <= -1.0 ) + return density * velocity_main * velocity_other; + else if ( machNumber <= 1.0 ) + return - density * speedOfSound / 4 * ( machNumber - 1.0 ) * ( machNumber - 1.0 ) * velocity_other; + else + return 0.0; + }; + + protected: + + RealType tau; + + RealType gamma; + + VelocityFieldPointer velocity; + + OperatorRightHandSideType rightHandSide; + + MeshFunctionPointer pressure; + + RealType dynamicalViscosity; + + MeshFunctionPointer density; + +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h new file mode 100644 index 000000000..04e41c015 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumX.h @@ -0,0 +1,410 @@ +/*************************************************************************** + VanLeerMomentumX.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumX +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west, velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east, velocity_x_east , pressure_east ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + - this->positiveMainMomentumFlux( density_west , velocity_x_west , pressure_west ) + - this->negativeMainMomentumFlux( density_center, velocity_x_center, pressure_center ) + + this->negativeMainMomentumFlux( density_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_x_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_x_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_x_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_x_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_x_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h new file mode 100644 index 000000000..65ac84828 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumY.h @@ -0,0 +1,381 @@ +/*************************************************************************** + VanLeerMomentumY.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumY +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumY< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_y_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_y_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + - this->positiveMainMomentumFlux( density_south , velocity_y_south , pressure_south ) + - this->negativeMainMomentumFlux( density_center, velocity_y_center, pressure_center ) + + this->negativeMainMomentumFlux( density_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_down , velocity_y_down , velocity_z_down , pressure_down ) + - this->negativeOtherMomentumFlux( density_center, velocity_y_center, velocity_z_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_up , velocity_y_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h new file mode 100644 index 000000000..125166cb8 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/VanLeer/VanLeerMomentumZ.h @@ -0,0 +1,322 @@ +/*************************************************************************** + VanLeerMomentumZ.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "VanLeerMomentumBase.h" + +namespace TNL { + +template< typename Mesh, + typename OperatorRightHandSide, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class VanLeerMomentumZ +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename OperatorRightHandSide, + typename Real, + typename Index > +class VanLeerMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > + : public VanLeerMomentumBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, OperatorRightHandSide, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef VanLeerMomentumBase< MeshType, OperatorRightHandSide, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "VanLeerMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& pressure_center = this->pressure.template getData< DeviceType >()[ center ]; + const RealType& pressure_west = this->pressure.template getData< DeviceType >()[ west ]; + const RealType& pressure_east = this->pressure.template getData< DeviceType >()[ east ]; + const RealType& pressure_north = this->pressure.template getData< DeviceType >()[ north ]; + const RealType& pressure_south = this->pressure.template getData< DeviceType >()[ south ]; + const RealType& pressure_up = this->pressure.template getData< DeviceType >()[ up ]; + const RealType& pressure_down = this->pressure.template getData< DeviceType >()[ down ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& density_west = this->density.template getData< DeviceType >()[ west ]; + const RealType& density_east = this->density.template getData< DeviceType >()[ east ]; + const RealType& density_north = this->density.template getData< DeviceType >()[ north ]; + const RealType& density_south = this->density.template getData< DeviceType >()[ south ]; + const RealType& density_up = this->density.template getData< DeviceType >()[ up ]; + const RealType& density_down = this->density.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return -hxInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_west , velocity_z_west , velocity_x_west , pressure_west ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_x_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_east , velocity_z_east , velocity_x_east , pressure_east ) + ) + -hyInverse * ( + this->positiveOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + - this->positiveOtherMomentumFlux( density_south , velocity_z_south , velocity_y_south , pressure_south ) + - this->negativeOtherMomentumFlux( density_center, velocity_z_center, velocity_y_center, pressure_center ) + + this->negativeOtherMomentumFlux( density_north , velocity_z_north , velocity_y_north , pressure_north ) + ) + -hzInverse * ( + this->positiveMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + - this->positiveMainMomentumFlux( density_down , velocity_z_down , pressure_down ) + - this->negativeMainMomentumFlux( density_center, velocity_z_center, pressure_center ) + + this->negativeMainMomentumFlux( density_up , velocity_z_up , pressure_up ) + ) + + + this->rightHandSide(u, entity, time); + } + + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlContinuityOperatorRightHandSide.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlContinuityOperatorRightHandSide.h new file mode 100644 index 000000000..2202fc217 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlContinuityOperatorRightHandSide.h @@ -0,0 +1,218 @@ +/*************************************************************************** + PrandtlContinuityOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include + +namespace TNL { + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlContinuityRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + + static String getType() + { + return String( "LaxFridrichsContinuity< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + protected: + +}; + + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlContinuityRightHandSide +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlContinuityRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlContinuityRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlContinuityRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlContinuityRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlContinuityRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlContinuityRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlContinuityRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + + return 0; + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlEnergyOperatorRightHandSide.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlEnergyOperatorRightHandSide.h new file mode 100644 index 000000000..132277f0a --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlEnergyOperatorRightHandSide.h @@ -0,0 +1,619 @@ +/*************************************************************************** + PrandtlEnergyOperatorRightHandSide.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlEnergyRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + PrandtlEnergyRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + static String getType() + { + return String( "LaxFridrichsEnergy< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + } + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + } + + protected: + + MeshFunctionPointer turbulentViscosity; + + VelocityFieldPointer velocity; + + RealType dynamicalViscosity; +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlEnergyRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlEnergyRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return +// 1D uT_11_x + 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity +// 1D_t_11_x + + + 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlEnergyRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return +// 2D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// vT_12_x + + ( ( velocity_x_northEast * velocity_y_east - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_west + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center - velocity_y_center * velocity_y_west + - velocity_y_center * velocity_y_center + velocity_y_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_21_y + + ( ( velocity_y_northEast * velocity_x_north - velocity_y_southEast * velocity_x_south + - velocity_y_northWest * velocity_x_north + velocity_y_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center - velocity_x_center * velocity_x_south + - velocity_x_center * velocity_x_center + velocity_x_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 2D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// ut_11_x + + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east * turbulentViscosity_east - velocity_y_southEast * velocity_x_east * turbulentViscosity_east + - velocity_y_northWest * velocity_x_west * turbulentViscosity_west + velocity_y_southWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + ) +// vt_12_x + + ( ( velocity_x_northEast * velocity_y_east * turbulentViscosity_east - velocity_x_southEast * velocity_y_east * turbulentViscosity_east + - velocity_x_northWest * velocity_y_west * turbulentViscosity_west + velocity_x_southWest * velocity_y_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_west * turbulentViscosity_west + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_west * velocity_y_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// ut_21_y + + ( ( velocity_y_northEast * velocity_x_north * turbulentViscosity_north - velocity_y_southEast * velocity_x_south * turbulentViscosity_south + - velocity_y_northWest * velocity_x_north * turbulentViscosity_north + velocity_y_southWest * velocity_x_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_south * turbulentViscosity_south + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_south * velocity_x_south * turbulentViscosity_south + ) * hySquareInverse + ) +// vt_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_south * turbulentViscosity_south + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_south * velocity_y_south * turbulentViscosity_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north * turbulentViscosity_north - velocity_x_southEast * velocity_y_south * turbulentViscosity_south + - velocity_x_northWest * velocity_y_north * turbulentViscosity_north + velocity_x_southWest * velocity_y_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlEnergyRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlEnergyRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& e, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D uT_11_x + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center - velocity_x_center * velocity_x_west + - velocity_x_center * velocity_x_center + velocity_x_west * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east - velocity_y_southEast * velocity_x_east + - velocity_y_northWest * velocity_x_west + velocity_y_southWest * velocity_x_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east - velocity_z_downEast * velocity_x_east + - velocity_z_upWest * velocity_x_west + velocity_z_downWest * velocity_x_west + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// vT_12_x + + ( ( velocity_x_northEast * velocity_y_east - velocity_x_southEast * velocity_y_east + - velocity_x_northWest * velocity_y_west + velocity_x_southWest * velocity_y_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center - velocity_y_center * velocity_y_west + - velocity_y_center * velocity_y_center + velocity_y_west * velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// wT_13_x + + ( ( velocity_x_upEast * velocity_z_east - velocity_x_downEast * velocity_z_east + - velocity_x_upWest * velocity_z_west + velocity_x_downWest * velocity_z_west + ) * hxInverse * hzInverse / 4 + + ( velocity_z_east * velocity_z_center - velocity_z_center * velocity_z_west + - velocity_z_center * velocity_z_center + velocity_z_west * velocity_z_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// uT_21_y + + ( ( velocity_y_northEast * velocity_x_north - velocity_y_southEast * velocity_x_south + - velocity_y_northWest * velocity_x_north + velocity_y_southWest * velocity_x_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center - velocity_x_center * velocity_x_south + + velocity_x_center * velocity_x_center + velocity_x_south * velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// 3D vT_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center - velocity_y_center * velocity_y_south + - velocity_y_center * velocity_y_center + velocity_y_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north - velocity_x_southEast * velocity_y_south + - velocity_x_northWest * velocity_y_north + velocity_x_southWest * velocity_y_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north - velocity_z_downNorth * velocity_y_north + - velocity_z_upSouth * velocity_y_south + velocity_z_downSouth * velocity_y_south + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// wT_23_y + + ( ( velocity_y_upNorth * velocity_z_north - velocity_y_downNorth * velocity_y_north + - velocity_y_upSouth * velocity_z_south + velocity_y_downSouth * velocity_z_south + ) * hyInverse * hzInverse / 4 + + ( velocity_z_north * velocity_z_center - velocity_z_center * velocity_z_south + - velocity_z_center * velocity_z_center + velocity_z_south * velocity_z_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// uT_31_z + + ( ( velocity_x_up * velocity_x_center - velocity_x_center * velocity_x_center + - velocity_x_center * velocity_x_down + velocity_x_down * velocity_x_down + ) * hzSquareInverse + + ( velocity_z_upEast * velocity_x_up - velocity_z_downEast * velocity_x_down + - velocity_z_upWest * velocity_x_up + velocity_z_downWest * velocity_x_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_z + + ( ( velocity_z_upNorth * velocity_y_up - velocity_z_downNorth * velocity_y_down + - velocity_z_upSouth * velocity_y_up + velocity_z_downSouth * velocity_y_down + ) * hyInverse * hzInverse / 4 + + ( velocity_x_up * velocity_y_center - velocity_x_center * velocity_y_down + - velocity_x_center * velocity_y_center + velocity_x_down * velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center - velocity_z_center * velocity_z_down + - velocity_z_center * velocity_z_center + velocity_z_down * velocity_z_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up - velocity_y_downNorth * velocity_z_down + - velocity_y_upSouth * velocity_z_up + velocity_y_downSouth * velocity_z_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up - velocity_x_downEast * velocity_z_down + - velocity_x_upWest * velocity_z_up + velocity_x_downWest * velocity_z_down + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// ut_11_x + + + ( 4.0 / 3.0 * ( velocity_x_east * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_west * turbulentViscosity_west + - velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_west * velocity_x_west * turbulentViscosity_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast * velocity_x_east * turbulentViscosity_east - velocity_y_southEast * velocity_x_east * turbulentViscosity_east + - velocity_y_northWest * velocity_x_west * turbulentViscosity_west + velocity_y_southWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast * velocity_x_east * turbulentViscosity_east - velocity_z_downEast * velocity_x_east * turbulentViscosity_east + - velocity_z_upWest * velocity_x_west * turbulentViscosity_west + velocity_z_downWest * velocity_x_west * turbulentViscosity_west + ) * hxInverse * hzInverse / 4 + ) +// vt_12_x + + ( ( velocity_x_northEast * velocity_y_east * turbulentViscosity_east - velocity_x_southEast * velocity_y_east * turbulentViscosity_east + - velocity_x_northWest * velocity_y_west * turbulentViscosity_west + velocity_x_southWest * velocity_y_west * turbulentViscosity_west + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_west * turbulentViscosity_west + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_west * velocity_y_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// wt_13_x + + ( ( velocity_x_upEast * velocity_z_east * turbulentViscosity_east - velocity_x_downEast * velocity_z_east * turbulentViscosity_east + - velocity_x_upWest * velocity_z_west * turbulentViscosity_west + velocity_x_downWest * velocity_z_west * turbulentViscosity_west + ) * hxInverse * hzInverse / 4 + + ( velocity_z_east * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_west * turbulentViscosity_west + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_west * velocity_z_west * turbulentViscosity_west + ) * hxSquareInverse + ) +// ut_21_y + + ( ( velocity_y_northEast * velocity_x_north * turbulentViscosity_north - velocity_y_southEast * velocity_x_south * turbulentViscosity_south + - velocity_y_northWest * velocity_x_north * turbulentViscosity_north + velocity_y_southWest * velocity_x_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_south * turbulentViscosity_south + + velocity_x_center * velocity_x_center * turbulentViscosity_center + velocity_x_south * velocity_x_south * turbulentViscosity_south + ) * hySquareInverse + ) +// vt_22_y + + ( 4.0 / 3.0 * ( velocity_y_north * velocity_y_center * turbulentViscosity_center - velocity_y_center * velocity_y_south * turbulentViscosity_south + - velocity_y_center * velocity_y_center * turbulentViscosity_center + velocity_y_south * velocity_y_south * turbulentViscosity_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast * velocity_y_north * turbulentViscosity_north - velocity_x_southEast * velocity_y_south * turbulentViscosity_south + - velocity_x_northWest * velocity_y_north * turbulentViscosity_north + velocity_x_southWest * velocity_y_south * turbulentViscosity_south + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth * velocity_y_north * turbulentViscosity_north - velocity_z_downNorth * velocity_y_north * turbulentViscosity_north + - velocity_z_upSouth * velocity_y_south * turbulentViscosity_south + velocity_z_downSouth * velocity_y_south * turbulentViscosity_south + ) * hyInverse * hzInverse / 4 + ) +// wt_23_y + + ( ( velocity_y_upNorth * velocity_z_north * turbulentViscosity_north - velocity_y_downNorth * velocity_y_north * turbulentViscosity_north + - velocity_y_upSouth * velocity_z_south * turbulentViscosity_south + velocity_y_downSouth * velocity_z_south * turbulentViscosity_south + ) * hyInverse * hzInverse / 4 + + ( velocity_z_north * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_south * turbulentViscosity_south + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_south * velocity_z_south * turbulentViscosity_south + ) * hySquareInverse + ) +// ut_31_z + + ( ( velocity_x_up * velocity_x_center * turbulentViscosity_center - velocity_x_center * velocity_x_center * turbulentViscosity_center + - velocity_x_center * velocity_x_down * turbulentViscosity_down + velocity_x_down * velocity_x_down * turbulentViscosity_down + ) * hzSquareInverse + + ( velocity_z_upEast * velocity_x_up * turbulentViscosity_up - velocity_z_downEast * velocity_x_down * turbulentViscosity_down + - velocity_z_upWest * velocity_x_up * turbulentViscosity_up + velocity_z_downWest * velocity_x_down * turbulentViscosity_down + ) * hxInverse * hzInverse / 4 + ) +// vt_32_z + + ( ( velocity_z_upNorth * velocity_y_up * turbulentViscosity_up - velocity_z_downNorth * velocity_y_down * turbulentViscosity_down + - velocity_z_upSouth * velocity_y_up * turbulentViscosity_up + velocity_z_downSouth * velocity_y_down * turbulentViscosity_down + ) * hyInverse * hzInverse / 4 + + ( velocity_x_up * velocity_y_center * turbulentViscosity_center - velocity_x_center * velocity_y_down * turbulentViscosity_down + - velocity_x_center * velocity_y_center * turbulentViscosity_center + velocity_x_down * velocity_y_down * turbulentViscosity_down + ) * hzSquareInverse + ) +// wt_33_z + + ( 4.0 / 3.0 * ( velocity_z_up * velocity_z_center * turbulentViscosity_center - velocity_z_center * velocity_z_down * turbulentViscosity_down + - velocity_z_center * velocity_z_center * turbulentViscosity_center + velocity_z_down * velocity_z_down * turbulentViscosity_down + ) * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth * velocity_z_up * turbulentViscosity_up - velocity_y_downNorth * velocity_z_down * turbulentViscosity_down + - velocity_y_upSouth * velocity_z_up * turbulentViscosity_up + velocity_y_downSouth * velocity_z_down * turbulentViscosity_down + ) * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast * velocity_z_up * turbulentViscosity_up - velocity_x_downEast * velocity_z_down * turbulentViscosity_down + - velocity_x_upWest * velocity_z_up * turbulentViscosity_up + velocity_x_downWest * velocity_z_down * turbulentViscosity_down + ) * hxInverse * hzInverse / 4 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumBaseOperatorRightHandSide.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumBaseOperatorRightHandSide.h new file mode 100644 index 000000000..1e6b807ce --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumBaseOperatorRightHandSide.h @@ -0,0 +1,66 @@ +/*************************************************************************** + PrandtlMomentumRightHandSideBase.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlMomentumRightHandSideBase +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + PrandtlMomentumRightHandSideBase() + : dynamicalViscosity( 1.0 ){}; + + void setVelocity( const VelocityFieldPointer& velocity ) + { + this->velocity = velocity; + }; + + void setDynamicalViscosity( const RealType& dynamicalViscosity ) + { + this->dynamicalViscosity = dynamicalViscosity; + }; + + void setDensity( const MeshFunctionType& density ) + { + this->density = density; + }; + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->turbulentViscosity = turbulentViscosity; + }; + + protected: + + VelocityFieldPointer velocity; + + MeshFunctionPointer turbulentViscosity; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumXOperatorRightHandSide.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumXOperatorRightHandSide.h new file mode 100644 index 000000000..200dcbc35 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumXOperatorRightHandSide.h @@ -0,0 +1,419 @@ +/*************************************************************************** + PrandtlMomentumXRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "PrandtlMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlMomentumXRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlMomentumXRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + return +// 1D T_11_x + 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + * this->dynamicalViscosity +// 1D t_11_x + + + 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + return +// 2D T_11_x + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hySquareInverse + ) * this->dynamicalViscosity +// t_11_x + + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + ) +// t_21_y + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + ) * hySquareInverse + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumX< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_u, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// 3D T_11_x + ( 4.0 / 3.0 * ( velocity_x_east - 2 * velocity_x_center + velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_21_y + + ( ( velocity_y_northEast - velocity_y_southEast - velocity_y_northWest + velocity_y_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_x_north - 2 * velocity_x_center + velocity_x_south + ) * hxSquareInverse + ) * this->dynamicalViscosity +// T_31_z + + ( ( velocity_z_upEast - velocity_z_downEast - velocity_z_upWest + velocity_z_downWest + ) * hxInverse * hzInverse / 4 + + ( velocity_x_up - 2 * velocity_x_center + velocity_x_down + ) * hzSquareInverse + ) * this->dynamicalViscosity +//t_11_x + + + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_west + ) * hxSquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest + velocity_z_downWest ) + ) * hxInverse * hzInverse / 4 + ) +// t_21_y + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north - turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + ) * hySquareInverse + ) +// t_31_z + + ( ( turbulentViscosity_up * ( velocity_z_upEast - velocity_z_upWest ) - turbulentViscosity_down * ( velocity_z_downEast - velocity_z_downWest ) + ) * hxInverse * hzInverse / 4 + + ( turbulentViscosity_up * velocity_x_up - ( turbulentViscosity_up + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_down + ) * hzSquareInverse + ); + + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumYOperatorRightHandSide.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumYOperatorRightHandSide.h new file mode 100644 index 000000000..0c2eb9506 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumYOperatorRightHandSide.h @@ -0,0 +1,397 @@ +/*************************************************************************** + PrandtlMomentumYRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "PrandtlMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlMomentumYRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlMomentumYRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlMomentumYRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + + + return +// 2D T_22_y + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + ) * this->dynamicalViscosity +// T_12_x + + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_west - 2 * velocity_y_center + velocity_y_east + ) * hxSquareInverse + ) * this->dynamicalViscosity + + +// t_22_y + ( 4.0 / 3.0 * ( turbulentViscosity_north * velocity_y_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_x_northEast - velocity_x_northWest ) - turbulentViscosity_south * ( velocity_x_southEast - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + ) +// t_12_x + + ( ( turbulentViscosity_east * (velocity_x_northEast - velocity_x_southEast ) - turbulentViscosity_west * (velocity_x_northWest - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_east * velocity_y_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_west + ) * hxSquareInverse + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlMomentumYRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumY< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_v, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// T_12_y + ( ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + + ( velocity_y_east - 2 * velocity_y_center + velocity_y_west + ) * hxSquareInverse + ) * this->dynamicalViscosity +// 3D T_22_y + + ( 4.0 / 3.0 * ( velocity_y_north - 2 * velocity_y_center + velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( velocity_x_northEast - velocity_x_southEast - velocity_x_northWest + velocity_x_southWest + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + ) * this->dynamicalViscosity +// T_32_y + + ( ( velocity_z_upNorth - velocity_z_downNorth - velocity_z_upSouth + velocity_z_downSouth + ) * hyInverse * hzInverse / 4 + + ( velocity_y_up - 2 * velocity_y_center + velocity_y_down + ) * hzSquareInverse + ) * this->dynamicalViscosity + + +// t_12_x + ( ( turbulentViscosity_east * ( velocity_x_northEast - velocity_x_southEast ) - turbulentViscosity_west * ( velocity_x_northWest - velocity_x_southWest ) + ) * hxInverse * hyInverse / 4 + + ( turbulentViscosity_east * velocity_y_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_west + ) * hxSquareInverse + ) +// t_22_y + + ( 4.0 / 3.0 * ( turbulentViscosity_north * velocity_y_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_south * velocity_y_south + ) * hySquareInverse + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_x_northEast - velocity_x_northWest ) - turbulentViscosity_south * ( velocity_x_southEast - velocity_x_southWest) + ) * hxInverse * hyInverse / 4 + - 2.0 / 3.0 * ( turbulentViscosity_north * ( velocity_z_upNorth - velocity_z_downNorth ) - turbulentViscosity_south * ( velocity_z_upSouth - velocity_z_downSouth ) + ) * hyInverse * hzInverse / 4 + ) +// t_32_z + + ( ( turbulentViscosity_up * ( velocity_z_upNorth - velocity_z_upSouth ) - turbulentViscosity_down * ( velocity_z_downNorth - velocity_z_downSouth ) + ) * hyInverse * hzInverse / 4 + + ( turbulentViscosity_up * velocity_y_up - ( turbulentViscosity_up + turbulentViscosity_center ) * velocity_y_center + turbulentViscosity_center * velocity_y_down + ) * hzSquareInverse + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumZOperatorRightHandSide.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumZOperatorRightHandSide.h new file mode 100644 index 000000000..78cc9062f --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumZOperatorRightHandSide.h @@ -0,0 +1,333 @@ +/*************************************************************************** + PrandtlMomentumZRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include "PrandtlMomentumBaseOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlMomentumZRightHandSide +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlMomentumZRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlMomentumRightHandSideBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 1, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 1, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 1 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlMomentumZRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlMomentumRightHandSideBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 2, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 2, "Wrong preimage function" ); + //const typename MeshEntity::template NeighborEntities< 2 >& neighborEntities = entity.getNeighborEntities(); + + return 0.0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class PrandtlMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Real, Index > + : public PrandtlMomentumRightHandSideBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef PrandtlMomentumRightHandSideBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::MeshFunctionPointer; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + static String getType() + { + return String( "LaxFridrichsMomentumZ< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + template< typename MeshFunction, typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshFunction& rho_w, + const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + static_assert( MeshEntity::getEntityDimension() == 3, "Wrong mesh entity dimensions." ); + static_assert( MeshFunction::getEntitiesDimension() == 3, "Wrong preimage function" ); + const typename MeshEntity::template NeighborEntities< 3 >& neighborEntities = entity.getNeighborEntities(); + + const RealType& hxInverse = entity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = entity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const RealType& hxSquareInverse = entity.getMesh().template getSpaceStepsProducts< -2, 0, 0 >(); + const RealType& hySquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, -2, 0 >(); + const RealType& hzSquareInverse = entity.getMesh().template getSpaceStepsProducts< 0, 0, -2 >(); + + const IndexType& center = entity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + const IndexType& northWest = neighborEntities.template getEntityIndex< -1, 1, 0 >(); + const IndexType& northEast = neighborEntities.template getEntityIndex< 1, 1, 0 >(); + const IndexType& southWest = neighborEntities.template getEntityIndex< -1, -1, 0 >(); + const IndexType& southEast = neighborEntities.template getEntityIndex< 1, -1, 0 >(); + const IndexType& upWest = neighborEntities.template getEntityIndex< -1, 0, 1 >(); + const IndexType& upEast = neighborEntities.template getEntityIndex< 1, 0, 1 >(); + const IndexType& upSouth = neighborEntities.template getEntityIndex< 0, -1, 1 >(); + const IndexType& upNorth = neighborEntities.template getEntityIndex< 0, 1, 1 >(); + const IndexType& downWest = neighborEntities.template getEntityIndex< -1, 0, -1 >(); + const IndexType& downEast = neighborEntities.template getEntityIndex< 1, 0, -1 >(); + const IndexType& downSouth = neighborEntities.template getEntityIndex< 0, -1, -1 >(); + const IndexType& downNorth = neighborEntities.template getEntityIndex< 0, 1, -1 >(); + + const RealType& turbulentViscosity_center = this->turbulentViscosity.template getData< DeviceType >()[ center ]; + const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; + const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; + const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; + const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + + const RealType& velocity_x_east = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_x_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_x_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_x_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_x_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_x_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_x_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_x_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ downEast ]; + + const RealType& velocity_y_north = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_y_south = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; + const RealType& velocity_y_southWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southWest ]; + const RealType& velocity_y_southEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ southEast ]; + const RealType& velocity_y_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_y_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_y_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_y_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ downSouth ]; + + const RealType& velocity_z_up = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_z_down = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ down ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_z_upWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upWest ]; + const RealType& velocity_z_upEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upEast ]; + const RealType& velocity_z_upNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upNorth ]; + const RealType& velocity_z_upSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ upSouth ]; + const RealType& velocity_z_downWest = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downWest ]; + const RealType& velocity_z_downEast = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downEast ]; + const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; + const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + + return +// T_13_x + ( ( velocity_z_east - 2 * velocity_z_center + velocity_z_west ) + * hxSquareInverse + + ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// T_23_y + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + * hySquareInverse + ) + * this->dynamicalViscosity +// 3D T_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ) + * this->dynamicalViscosity +// t_13_x + + ( ( turbulentViscosity_east * velocity_z_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_west ) + * hxSquareInverse + + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest + velocity_x_downWest ) ) + * hxInverse * hzInverse / 4 + ) +// t_23_y + + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + * hySquareInverse + ) +// t_33_z + + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + * hzSquareInverse + - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + * hyInverse * hzInverse / 4 + - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + * hxInverse * hzInverse / 4 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h new file mode 100644 index 000000000..9df47e1e8 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h @@ -0,0 +1,130 @@ +/*************************************************************************** + PrandtlOpratorRightHandSide.h - description + ------------------- + begin : Feb 18, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include + +#include "PrandtlContinuityOperatorRightHandSide.h" +#include "PrandtlEnergyOperatorRightHandSide.h" +#include "PrandtlMomentumXOperatorRightHandSide.h" +#include "PrandtlMomentumYOperatorRightHandSide.h" +#include "PrandtlMomentumZOperatorRightHandSide.h" + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class PrandtlOperatorRightHandSide +{ + public: + typedef Mesh MeshType; + typedef Real RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef Index IndexType; + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + static const int Dimensions = Mesh::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VectorFieldType; + + typedef PrandtlContinuityRightHandSide< Mesh, Real, Index > ContinuityOperatorRightHandSideType; + typedef PrandtlMomentumXRightHandSide< Mesh, Real, Index > MomentumXOperatorRightHandSideType; + typedef PrandtlMomentumYRightHandSide< Mesh, Real, Index > MomentumYOperatorRightHandSideType; + typedef PrandtlMomentumZRightHandSide< Mesh, Real, Index > MomentumZOperatorRightHandSideType; + typedef PrandtlEnergyRightHandSide< Mesh, Real, Index > EnergyOperatorRightHandSideType; + + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Pointers::SharedPointer< VectorFieldType > VectorFieldPointer; + typedef Pointers::SharedPointer< MeshType > MeshPointer; + + typedef Pointers::SharedPointer< ContinuityOperatorRightHandSideType > ContinuityOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumXOperatorRightHandSideType > MomentumXOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumYOperatorRightHandSideType > MomentumYOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< MomentumZOperatorRightHandSideType > MomentumZOperatorRightHandSidePointer; + typedef Pointers::SharedPointer< EnergyOperatorRightHandSideType > EnergyOperatorRightHandSidePointer; + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "dynamical-viscosity", "Value of dynamical (real) viscosity in the Navier-Stokes equation", 1.0 ); + } + + PrandtlOperatorRightHandSide() + : dynamicalViscosity( 1.0 ) {} + + bool setup( const MeshPointer& meshPointer, + const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + this->dynamicalViscosity = parameters.getParameter< double >( prefix + "dynamical-viscosity" ); + this->momentumXOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumYOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->momentumZOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + this->energyOperatorRightHandSidePointer->setDynamicalViscosity( dynamicalViscosity ); + return true; + } + + void setVelocity( const VectorFieldPointer& velocity ) + { + this->continuityOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumXOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumYOperatorRightHandSidePointer->setVelocity( velocity ); + this->momentumZOperatorRightHandSidePointer->setVelocity( velocity ); + this->energyOperatorRightHandSidePointer->setVelocity( velocity ); + } + + void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) + { + this->momentumXOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumYOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->momentumZOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + this->energyOperatorRightHandSidePointer->setTurbulentViscosity( turbulentViscosity ); + } + + const ContinuityOperatorRightHandSidePointer& getContinuityOperatorRightHandSide() const + { + return this->continuityOperatorRightHandSidePointer; + } + + const MomentumXOperatorRightHandSidePointer& getMomentumXOperatorRightHandSide() const + { + return this->momentumXOperatorRightHandSidePointer; + } + + const MomentumYOperatorRightHandSidePointer& getMomentumYOperatorRightHandSide() const + { + return this->momentumYOperatorRightHandSidePointer; + } + + const MomentumZOperatorRightHandSidePointer& getMomentumZOperatorRightHandSide() const + { + return this->momentumZOperatorRightHandSidePointer; + } + + const EnergyOperatorRightHandSidePointer& getEnergyOperatorRightHandSide() const + { + return this->energyOperatorRightHandSidePointer; + } + + protected: + + ContinuityOperatorRightHandSidePointer continuityOperatorPointer; + MomentumXOperatorRightHandSidePointer momentumXOperatorPointer; + MomentumYOperatorRightHandSidePointer momentumYOperatorPointer; + MomentumZOperatorRightHandSidePointer momentumZOperatorPointer; + EnergyOperatorRightHandSidePointer energyOperatorPointer; + + RealType dynamicalViscosity; +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/PhysicalVariablesGetter.h b/src/Examples/turbulent-flows/zero-equation-model/PhysicalVariablesGetter.h new file mode 100644 index 000000000..703bbabbf --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/PhysicalVariablesGetter.h @@ -0,0 +1,134 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include "CompressibleConservativeVariables.h" +#include "turbulentViscosityGetter.h" + +namespace TNL { + +template< typename Mesh > +class PhysicalVariablesGetter +{ + public: + + typedef Mesh MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + class VelocityGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + VelocityGetter( MeshFunctionPointer density, + MeshFunctionPointer momentum ) + : density( density ), momentum( momentum ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + if( density.template getData< DeviceType >()( meshEntity ) == 0.0 ) + return 0; + else + return momentum.template getData< DeviceType >()( meshEntity ) / + density.template getData< DeviceType >()( meshEntity ); + } + + protected: + const MeshFunctionPointer density, momentum; + }; + + class PressureGetter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + PressureGetter( MeshFunctionPointer density, + MeshFunctionPointer energy, + VelocityFieldPointer momentum, + const RealType& gamma ) + : density( density ), energy( energy ), momentum( momentum ), gamma( gamma ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + const RealType e = energy.template getData< DeviceType >()( meshEntity ); + const RealType rho = density.template getData< DeviceType >()( meshEntity ); + const RealType momentumNorm = momentum.template getData< DeviceType >().getVector( meshEntity ).lpNorm( 2.0 ); + if( rho == 0.0 ) + return 0; + else + return ( gamma - 1.0 ) * ( e - 0.5 * momentumNorm * momentumNorm / rho ); + } + + protected: + const MeshFunctionPointer density, energy; + const VelocityFieldPointer momentum; + const RealType gamma; + }; + + + void getVelocity( const ConservativeVariablesPointer& conservativeVariables, + VelocityFieldPointer& velocity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, VelocityGetter > evaluator; + for( int i = 0; i < Dimensions; i++ ) + { + Pointers::SharedPointer< VelocityGetter, DeviceType > velocityGetter( conservativeVariables->getDensity(), + ( *conservativeVariables->getMomentum() )[ i ] ); + evaluator.evaluate( ( *velocity )[ i ], velocityGetter ); + } + } + + void getPressure( const ConservativeVariablesPointer& conservativeVariables, + const RealType& gamma, + MeshFunctionPointer& pressure ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, PressureGetter > evaluator; + Pointers::SharedPointer< PressureGetter, DeviceType > pressureGetter( conservativeVariables->getDensity(), + conservativeVariables->getEnergy(), + conservativeVariables->getMomentum(), + gamma ); + evaluator.evaluate( pressure, pressureGetter ); + } + + void getTurbulentViscocsity( const ConservativeVariablesPointer& conservativeVariables, + VelocityFieldPointer& velocity, + const RealType& mixingLength, + MeshFunctionPointer& turbulentViscosity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, TurbulentViscosityGetter < MeshType > > evaluator; + Pointers::SharedPointer< TurbulentViscosityGetter < MeshType >, DeviceType > turbulentViscosityGetter( conservativeVariables->getDensity(), + velocity, + mixingLength ); + evaluator.evaluate( turbulentViscosity, turbulentViscosityGetter ); + } +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/RiemannProblemInitialCondition.h b/src/Examples/turbulent-flows/zero-equation-model/RiemannProblemInitialCondition.h new file mode 100644 index 000000000..ff66ff8b7 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/RiemannProblemInitialCondition.h @@ -0,0 +1,1413 @@ +/*************************************************************************** + RiemannProblemInitialCondition.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { +template +class RiemannProblemInitialConditionSetter +{ + +}; + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 1,MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 1,MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + if ( i < this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + { + CellType cell(mesh, CoordinatesType(i)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 2,MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) ) + { + CellType cell(mesh, CoordinatesType(i,j)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + +template +class RiemannProblemInitialConditionSetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex > > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + + void setDiscontinuity(PointType discontinuityPlacement) + { + this->discontinuityPlacement = discontinuityPlacement; + }; + void setDensity(RealType NWUDensity, + RealType NEUDensity, + RealType SWUDensity, + RealType SEUDensity, + RealType NWDDensity, + RealType NEDDensity, + RealType SWDDensity, + RealType SEDDensity) + { + this->NWUDensity = NWUDensity; + this->NEUDensity = NEUDensity; + this->SWUDensity = SWUDensity; + this->SEUDensity = SEUDensity; + this->NWDDensity = NWDDensity; + this->NEDDensity = NEDDensity; + this->SWDDensity = SWDDensity; + this->SEDDensity = SEDDensity; + }; + + void setMomentum(PointType NWUMomentum, + PointType NEUMomentum, + PointType SWUMomentum, + PointType SEUMomentum, + PointType NWDMomentum, + PointType NEDMomentum, + PointType SWDMomentum, + PointType SEDMomentum) + { + this->NWUMomentum = NWUMomentum; + this->NEUMomentum = NEUMomentum; + this->SWUMomentum = SWUMomentum; + this->SEUMomentum = SEUMomentum; + this->NWDMomentum = NWDMomentum; + this->NEDMomentum = NEDMomentum; + this->SWDMomentum = SWDMomentum; + this->SEDMomentum = SEDMomentum; + }; + + void setEnergy(RealType NWUEnergy, + RealType NEUEnergy, + RealType SWUEnergy, + RealType SEUEnergy, + RealType NWDEnergy, + RealType NEDEnergy, + RealType SWDEnergy, + RealType SEDEnergy) + { + this->NWUEnergy = NWUEnergy; + this->NEUEnergy = NEUEnergy; + this->SWUEnergy = SWUEnergy; + this->SEUEnergy = SEUEnergy; + this->NWDEnergy = NWDEnergy; + this->NEDEnergy = NEDEnergy; + this->SWDEnergy = SWDEnergy; + this->SEDEnergy = SEDEnergy; + }; + + void setGamma(RealType gamma) + { + this->gamma = gamma; + }; + + void placeDensity(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NWDDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->NEDDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SWUDensity); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getDensity()).setValue(cell, this->SEUDensity); + } + }; + + void placeMomentum(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWDMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEDMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NWDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NWDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NWDMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->NEDMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->NEDMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->NEDMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SWUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SWUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SWUMomentum[ 2 ]); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* (* conservativeVariables.getMomentum())[ 0 ]).setValue(cell, this->SEUMomentum[ 0 ]); + (* (* conservativeVariables.getMomentum())[ 1 ]).setValue(cell, this->SEUMomentum[ 1 ]); + (* (* conservativeVariables.getMomentum())[ 2 ]).setValue(cell, this->SEUMomentum[ 2 ]); + } + }; + + void placeEnergy(CompressibleConservativeVariables< MeshType >& conservativeVariables) + { + typedef typename MeshType::Cell CellType; + typedef typename MeshType::CoordinatesType CoordinatesType; + MeshType mesh = (* conservativeVariables.getDensity()).getMesh(); + for( int i = 0; i < mesh.getDimensions().x(); i++) + for( int j = 0; j < mesh.getDimensions().y(); j++) + for ( int k = 0; k < mesh.getDimensions().z(); k++) + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NWDEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k <= this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->NEDEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j <= this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); + } + else + if ( ( i <= this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SWUEnergy); + } + else + if ( ( i > this->discontinuityPlacement[ 0 ] * mesh.getDimensions().x() ) + && ( j > this->discontinuityPlacement[ 1 ] * mesh.getDimensions().y() ) + && ( k > this->discontinuityPlacement[ 2 ] * mesh.getDimensions().z() ) ) + { + CellType cell(mesh, CoordinatesType(i,j,k)); + cell.refresh(); + (* conservativeVariables.getEnergy()).setValue(cell, this->SEUEnergy); + } + }; + + PointType discontinuityPlacement; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType gamma; +}; + +template< typename Mesh > +class RiemannProblemInitialCondition +{ + public: + + typedef Mesh MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Containers::StaticVector< Dimensions, RealType > PointType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef Functions::VectorField< Dimensions, MeshType > VectorFieldType; + + RiemannProblemInitialCondition() + : discontinuityPlacement( 0.5 ), + leftDensity( 1.0 ), rightDensity( 1.0 ), + leftVelocity( -2.0 ), rightVelocity( 2.0 ), + leftPressure( 0.4 ), rightPressure( 0.4 ), + gamma( 1.67 ){} + + static void configSetup( Config::ConfigDescription& config, + const String& prefix = "" ) + { + config.addEntry< double >( prefix + "discontinuity-placement-0", "x-coordinate of the discontinuity placement.", 0.5 ); + config.addEntry< double >( prefix + "discontinuity-placement-1", "y-coordinate of the discontinuity placement.", 0.5 ); + config.addEntry< double >( prefix + "discontinuity-placement-2", "z-coordinate of the discontinuity placement.", 0.5 ); +/* + config.addEntry< double >( prefix + "left-density", "Density on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-density", "Density on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "left-velocity-0", "x-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "left-velocity-1", "y-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "left-velocity-2", "z-coordinate of the velocity on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-velocity-0", "x-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "right-velocity-1", "y-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "right-velocity-2", "z-coordinate of the velocity on the right side of the discontinuity.", 0.0 ); + config.addEntry< double >( prefix + "left-pressure", "Pressure on the left side of the discontinuity.", 1.0 ); + config.addEntry< double >( prefix + "right-pressure", "Pressure on the right side of the discontinuity.", 0.0 ); +*/ + config.addEntry< double >( prefix + "NWU-density", "This sets a value of northwest up density.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-0", "This sets a value of northwest up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-1", "This sets a value of northwest up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-velocity-2", "This sets a value of northwest up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWU-pressure", "This sets a value of northwest up pressure.", 1.0 ); + config.addEntry< double >( prefix + "SWU-density", "This sets a value of southwest up density.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-0", "This sets a value of southwest up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-1", "This sets a value of southwest up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-velocity-2", "This sets a value of southwest up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWU-pressure", "This sets a value of southwest up pressure.", 1.0 ); + config.addEntry< double >( prefix + "NWD-density", "This sets a value of northwest down density.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-0", "This sets a value of northwest down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-1", "This sets a value of northwest down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-velocity-2", "This sets a value of northwest down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NWD-pressure", "This sets a value of northwest down pressure.", 1.0 ); + config.addEntry< double >( prefix + "SWD-density", "This sets a value of southwest down density.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-0", "This sets a value of southwest down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-1", "This sets a value of southwest down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-velocity-2", "This sets a value of southwest down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SWD-pressure", "This sets a value of southwest down pressure.", 1.0 ); + config.addEntry< double >( prefix + "NEU-density", "This sets a value of northeast up density.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-0", "This sets a value of northeast up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-1", "This sets a value of northeast up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-velocity-2", "This sets a value of northeast up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NEU-pressure", "This sets a value of northeast up pressure.", 1.0 ); + config.addEntry< double >( prefix + "SEU-density", "This sets a value of southeast up density.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-0", "This sets a value of southeast up x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-1", "This sets a value of southeast up y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-velocity-2", "This sets a value of southeast up z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SEU-pressure", "This sets a value of southeast up pressure.", 1.0 ); + config.addEntry< double >( prefix + "NED-density", "This sets a value of northeast down density.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-0", "This sets a value of northeast down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-1", "This sets a value of northeast down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-velocity-2", "This sets a value of northeast down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "NED-pressure", "This sets a value of northeast down pressure.", 1.0 ); + config.addEntry< double >( prefix + "SED-density", "This sets a value of southeast down density.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-0", "This sets a value of southeast down x velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-1", "This sets a value of southeast down y velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-velocity-2", "This sets a value of southeast down z velocity.", 1.0 ); + config.addEntry< double >( prefix + "SED-pressure", "This sets a value of southeast down pressure.", 1.0 ); + config.addEntry< double >( prefix + "gamma", "Gamma in the ideal gas state equation.", 1.4 ); + + config.addEntry< String >( prefix + "initial", " One of predefined initial condition.", "none"); + config.addEntryEnum< String >( "none" ); + config.addEntryEnum< String >( "1D_2" ); + config.addEntryEnum< String >( "1D_3a" ); + config.addEntryEnum< String >( "1D_4" ); + config.addEntryEnum< String >( "1D_5" ); + config.addEntryEnum< String >( "1D_6" ); + config.addEntryEnum< String >( "1D_Noh" ); + config.addEntryEnum< String >( "1D_peak" ); + config.addEntryEnum< String >( "2D_3" ); + config.addEntryEnum< String >( "2D_4" ); + config.addEntryEnum< String >( "2D_6" ); + config.addEntryEnum< String >( "2D_12" ); + config.addEntryEnum< String >( "2D_15" ); + config.addEntryEnum< String >( "2D_17" ); + } + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + String initial = parameters.getParameter< String >( prefix + "initial" ); + if(initial == prefix + "none") + { + this->discontinuityPlacement.setup( parameters, prefix + "discontinuity-placement-" ); + this->gamma = parameters.getParameter< double >( prefix + "gamma" ); +/* + this->leftVelocity.setup( parameters, prefix + "left-velocity-" ); + this->rightVelocity.setup( parameters, prefix + "right-velocity-" ); + this->leftDensity = parameters.getParameter< double >( prefix + "left-density" ); + this->rightDensity = parameters.getParameter< double >( prefix + "right-density" ); + this->leftPressure = parameters.getParameter< double >( prefix + "left-pressure" ); + this->rightPressure = parameters.getParameter< double >( prefix + "right-pressure" ); +*/ + + this->NWUDensity = parameters.getParameter< RealType >( prefix + "NWU-density" ); + this->NWUVelocity.setup( parameters, prefix + "NWU-velocity-" ); + this->NWUPressure = parameters.getParameter< RealType >( prefix + "NWU-pressure" ); + this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); + this->NWUMomentum = NWUVelocity * NWUDensity; + + this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); + this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); + this->SWUPressure = parameters.getParameter< RealType >( prefix + "SWU-pressure" ); + this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); + this->SWUMomentum = SWUVelocity * SWUDensity; + + this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); + this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); + this->NWDPressure = parameters.getParameter< RealType >( prefix + "NWD-pressure" ); + this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); + this->NWDMomentum = NWDVelocity * NWDDensity; + + this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); + this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); + this->SWDPressure = parameters.getParameter< RealType >( prefix + "SWD-pressure" ); + this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); + this->SWDMomentum = SWDVelocity * SWDDensity; + + this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); + this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); + this->NEUPressure = parameters.getParameter< RealType >( prefix + "NEU-pressure" ); + this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); + this->NEUMomentum = NEUVelocity * NEUDensity; + + this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); + this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); + this->SEUPressure = parameters.getParameter< RealType >( prefix + "SEU-pressure" ); + this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); + this->SEUMomentum = SEUVelocity * SEUDensity; + + this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); + this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); + this->NEDPressure = parameters.getParameter< RealType >( prefix + "NED-pressure" ); + this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); + this->NEDMomentum = NEDVelocity * NEDDensity; + + this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); + this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); + this->SEDPressure = parameters.getParameter< RealType >( prefix + "SED-pressure" ); + this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); + this->SEDMomentum = SEDVelocity * SEDDensity; + } + if(initial == prefix + "1D_2") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -2.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 2.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_3a") + predefinedInitialCondition( 1.4, 0.8, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 1000.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.01, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -19.59745, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -19.59745, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_4") + predefinedInitialCondition( 1.666, 0.4, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 5.99924, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 5.99242, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 460.894, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 46.095, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 19.5975, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -6.19633, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_5") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_6") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.4, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.1, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_Noh") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 0.000001, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 0.000001, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "1D_peak") + predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.0, 0.12612, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.0, 6.5915, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.0, 782.929, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.0, 3.15449, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 8.90470, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 2.26542, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_3") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5323, 0.138, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.5, 0.5323, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.3, 0.029, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.5, 0.3, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 1.206, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 1.206, 1.206, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 1.206, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_4") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5065, 1.1, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.1, 0.5065, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.35, 1.1, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.1, 0.35, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.8939, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.8939, 0.8939, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.8939, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + + if(initial == prefix + "2D_6") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 2.0, 1.0, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 3.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.75, 0.5, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + -0.75, 0.5, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.75, -0.5, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + -0.75, -0.5, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_12") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 1.0, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 0.5313, 1.0, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 1.0, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 0.4, 1.0, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.7276, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 0.7276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + + if(initial == prefix + "2D_15") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 0.5197, 0.8, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 0.5313, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 0.4, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + -0.6259, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.1, -0.3, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.1, -0.3, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.1, 0.4276, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + if(initial == prefix + "2D_17") + predefinedInitialCondition( 1.666, 0.5, 0.5, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, + 0.0, 0.0, 2.0, 1.0625, //double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + 0.0, 0.0, 1.0, 0.5197, //double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + 0.0, 0.0, 1.0, 0.4, //double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + 0.0, 0.0, 1.0, 0.4, //double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + 0.0, -0.3, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + 0.0, 0.2145, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + 0.0, -0.4, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + 0.0, 1.1259, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ); + return true; + } + + void setDiscontinuityPlacement( const PointType& v ) + { + this->discontinuityPlacement = v; + } + + const PointType& getDiscontinuityPlasement() const + { + return this->discontinuityPlacement; + } + + void setLeftDensity( const RealType& leftDensity ) + { + this->leftDensity = leftDensity; + } + + const RealType& getLeftDensity() const + { + return this->leftDensity; + } + + void setRightDensity( const RealType& rightDensity ) + { + this->rightDensity = rightDensity; + } + + const RealType& getRightDensity() const + { + return this->rightDensity; + } + + void setLeftVelocity( const PointType& leftVelocity ) + { + this->leftVelocity = leftVelocity; + } + + const PointType& getLeftVelocity() const + { + return this->leftVelocity; + } + + void setRightVelocity( const RealType& rightVelocity ) + { + this->rightVelocity = rightVelocity; + } + + const PointType& getRightVelocity() const + { + return this->rightVelocity; + } + + void setLeftPressure( const RealType& leftPressure ) + { + this->leftPressure = leftPressure; + } + + const RealType& getLeftPressure() const + { + return this->leftPressure; + } + + void setRightPressure( const RealType& rightPressure ) + { + this->rightPressure = rightPressure; + } + + const RealType& getRightPressure() const + { + return this->rightPressure; + } + + + void predefinedInitialCondition( double preGamma, double preDiscX, double preDiscY, double preDiscZ, + double preNWUDensity, double preSWUDensity, double preNWDDensity, double preSWDDensity, + double preNEUDensity, double preSEUDensity, double preNEDDensity, double preSEDDensity, + double preNWUPressure, double preSWUPressure, double preNWDPressure, double preSWDPressure, + double preNEUPressure, double preSEUPressure, double preNEDPressure, double preSEDPressure, + double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, + double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, + double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, + double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, + double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, + double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, + double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + ) + + { + this->discontinuityPlacement = PointLoad(preDiscX, preDiscY, preDiscZ); + this->gamma = preGamma; + + this->NWUDensity = preNWUDensity; + this->NWUVelocity = PointLoad(preNWUVelocityX, preNWUVelocityY, preNWUVelocityZ); + this->NWUPressure = preNWUPressure; + this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); + this->NWUMomentum = NWUVelocity * NWUDensity; + + this->SWUDensity = preNWUDensity; + this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); + this->SWUPressure = preSWUPressure; + this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); + this->SWUMomentum = SWUVelocity * SWUDensity; + + this->NWDDensity = preNWDDensity; + this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); + this->NWDPressure = preNWDPressure; + this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); + this->NWDMomentum = NWDVelocity * NWDDensity; + + this->SWDDensity = preSWDDensity; + this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); + this->SWDPressure = preSWDPressure; + this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); + this->SWDMomentum = SWDVelocity * SWDDensity; + + this->NEUDensity = preNEUDensity; + this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); + this->NEUPressure = preNEUPressure; + this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); + this->NEUMomentum = NEUVelocity * NEUDensity; + + this->SEUDensity = preSEUDensity; + this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); + this->SEUPressure = preSEUPressure; + this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); + this->SEUMomentum = SEUVelocity * SEUDensity; + + this->NEDDensity = preNEDDensity; + this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); + this->NEDPressure = preNEDPressure; + this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); + this->NEDMomentum = NEDVelocity * NEDDensity; + + this->SEDDensity = preSEDDensity; + this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); + this->SEDPressure = preSEDPressure; + this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); + this->SEDMomentum = SEDVelocity * SEDDensity; + + } + + PointType PointLoad( RealType ValueX, RealType ValueY, RealType ValueZ) + { + PointType point; + switch (Dimensions) + { + case 1: point[ 0 ] = ValueX; + break; + case 2: point[ 0 ] = ValueX; + point[ 1 ] = ValueY; + break; + case 3: point[ 0 ] = ValueX; + point[ 1 ] = ValueY; + point[ 2 ] = ValueZ; + break; + } + return point; + } + + RealType Energy( RealType Density, RealType Pressure, RealType gamma, PointType Velocity) + { + RealType energy; + switch (Dimensions) + { + case 1: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ))); + break; + case 2: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ))); + break; + case 3: energy = (Pressure / (gamma -1.0) + 0.5 * Density * (std::pow(Velocity[ 0 ], 2 ) + std::pow(Velocity[ 1 ], 2 ) + std::pow(Velocity[ 2 ], 2 ))); + break; // druhou mocninu ps8t jako sou4in + } + return energy; + } + + void setInitialCondition( CompressibleConservativeVariables< MeshType >& conservativeVariables, + const PointType& center = PointType( 0.0 ) ) + { + RiemannProblemInitialConditionSetter* variablesSetter = new RiemannProblemInitialConditionSetter; + variablesSetter->setGamma(this->gamma); + variablesSetter->setDensity(this->NWUDensity, + this->NEUDensity, + this->SWUDensity, + this->SEUDensity, + this->NWDDensity, + this->NEDDensity, + this->SWDDensity, + this->SEDDensity); + variablesSetter->setMomentum(this->NWUMomentum, + this->NEUMomentum, + this->SWUMomentum, + this->SEUMomentum, + this->NWDMomentum, + this->NEDMomentum, + this->SWDMomentum, + this->SEDMomentum); + variablesSetter->setEnergy(this->NWUEnergy, + this->NEUEnergy, + this->SWUEnergy, + this->SEUEnergy, + this->NWDEnergy, + this->NEDEnergy, + this->SWDEnergy, + this->SEDEnergy); + variablesSetter->setDiscontinuity(this->discontinuityPlacement); + variablesSetter->placeDensity(conservativeVariables); + variablesSetter->placeMomentum(conservativeVariables); + variablesSetter->placeEnergy(conservativeVariables); + +// for cyklus i = 0 to mesh.getDimensions().x() j pro .y() a k pro .z() +// typedef typename MeshType::Cell CellType +// typedef typename MeshType::CoordinatesType CoordinatesType +// Celltype cell(mesh, CoordinatesType(i,j)) +// p59stup do density setElement(mesh.template getEntityIndex< CellType >(cell), hodnota, kterou budu zapisovat) +// pomocn8 t59da, kterou budu specialiyovat p5es r;zn0 dimenze gridu + +/* + typedef Functions::Analytic::VectorNorm< Dimensions, RealType > VectorNormType; + typedef Operators::Analytic::Sign< Dimensions, RealType > SignType; + typedef Functions::OperatorFunction< SignType, VectorNormType > InitialConditionType; + typedef SharedPointer< InitialConditionType, DeviceType > InitialConditionPointer; + + InitialConditionPointer initialCondition; + initialCondition->getFunction().setCenter( center ); + initialCondition->getFunction().setMaxNorm( true ); + initialCondition->getFunction().setRadius( discontinuityPlacement[ 0 ] ); + discontinuityPlacement *= 1.0 / discontinuityPlacement[ 0 ]; + for( int i = 1; i < Dimensions; i++ ) + discontinuityPlacement[ i ] = 1.0 / discontinuityPlacement[ i ]; + initialCondition->getFunction().setAnisotropy( discontinuityPlacement ); + initialCondition->getFunction().setMultiplicator( -1.0 ); + + Functions::MeshFunctionEvaluator< MeshFunctionType, InitialConditionType > evaluator; +*/ + /**** + * Density + */ +/* + conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); +*/ +/* + initialCondition->getOperator().setPositiveValue( leftDensity ); + initialCondition->getOperator().setNegativeValue( rightDensity ); + evaluator.evaluate( conservativeVariables.getDensity(), initialCondition ); + conservativeVariables.getDensity()->write( "density.gplt", "gnuplot" ); +*/ + /**** + * Momentum + */ + +/* + for( int i = 0; i < Dimensions; i++ ) + { + initialCondition->getOperator().setPositiveValue( leftDensity * leftVelocity[ i ] ); + initialCondition->getOperator().setNegativeValue( rightDensity * rightVelocity[ i ] ); + evaluator.evaluate( conservativeVariables.getMomentum()[ i ], initialCondition ); + } +*/ + /**** + * Energy + */ +/* + conservativeVariables.getEnergy()->write( "energy-init", "gnuplot" ); +*/ +/* + const RealType leftKineticEnergy = leftVelocity.lpNorm( 2.0 ); + const RealType rightKineticEnergy = rightVelocity.lpNorm( 2.0 ); + const RealType leftEnergy = leftPressure / ( gamma - 1.0 ) + 0.5 * leftDensity * leftKineticEnergy * leftKineticEnergy; + const RealType rightEnergy = rightPressure / ( gamma - 1.0 ) + 0.5 * rightDensity * rightKineticEnergy * rightKineticEnergy; + initialCondition->getOperator().setPositiveValue( leftEnergy ); + initialCondition->getOperator().setNegativeValue( rightEnergy ); + evaluator.evaluate( (* conservativeVariables.getEnergy()), initialCondition ); + (* conservativeVariables.getEnergy())->write( "energy-init", "gnuplot" ); +*/ + } + + + protected: + + PointType discontinuityPlacement; + PointType NWUVelocity, NEUVelocity, SWUVelocity, SEUVelocity, NWDVelocity, NEDVelocity, SWDVelocity, SEDVelocity; + RealType NWUDensity, NEUDensity, SWUDensity, SEUDensity, NWDDensity, NEDDensity, SWDDensity, SEDDensity; + RealType NWUPressure, NEUPressure, SWUPressure, SEUPressure, NWDPressure, NEDPressure, SWDPressure, SEDPressure; + RealType NWUEnergy, NEUEnergy, SWUEnergy, SEUEnergy, NWDEnergy, NEDEnergy, SWDEnergy, SEDEnergy; + PointType NWUMomentum, NEUMomentum, SWUMomentum, SEUMomentum, NWDMomentum, NEDMomentum, SWDMomentum, SEDMomentum; + RealType leftDensity, rightDensity; + PointType leftVelocity, rightVelocity; + RealType leftPressure, rightPressure; + + RealType gamma; // gamma in the ideal gas state equation +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/flowsBuildConfigTag.h b/src/Examples/turbulent-flows/zero-equation-model/flowsBuildConfigTag.h new file mode 100644 index 000000000..c40b793b9 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/flowsBuildConfigTag.h @@ -0,0 +1,72 @@ +#ifndef FLOWSBUILDCONFIGTAG_H_ +#define FLOWSBUILDCONFIGTAG_H_ + +#include +#include + +namespace TNL { + +class flowsBuildConfigTag{}; + +namespace Solvers { + +/**** + * Turn off support for float and long double. + */ +template<> struct ConfigTagReal< flowsBuildConfigTag, float > { enum { enabled = false }; }; +template<> struct ConfigTagReal< flowsBuildConfigTag, long double > { enum { enabled = false }; }; + +/**** + * Turn off support for short int and long int indexing. + */ +template<> struct ConfigTagIndex< flowsBuildConfigTag, short int >{ enum { enabled = false }; }; +template<> struct ConfigTagIndex< flowsBuildConfigTag, long int >{ enum { enabled = false }; }; + +//template< int Dimension > struct ConfigTagDimension< flowsBuildConfigTag, Dimension >{ enum { enabled = ( Dimension == 1 ) }; }; + +/**** + * Use of Grid is enabled for allowed dimensions and Real, Device and Index types. + */ +/*template< int Dimension, typename Real, typename Device, typename Index > + struct ConfigTagMesh< flowsBuildConfigTag, Meshes::Grid< Dimension, Real, Device, Index > > + { enum { enabled = ConfigTagDimension< flowsBuildConfigTag, Dimension >::enabled && + ConfigTagReal< flowsBuildConfigTag, Real >::enabled && + ConfigTagDevice< flowsBuildConfigTag, Device >::enabled && + ConfigTagIndex< flowsBuildConfigTag, Index >::enabled }; }; +*/ +/**** + * Please, chose your preferred time discretisation here. + */ +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, ExplicitTimeDiscretisationTag >{ enum { enabled = true }; }; +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, SemiImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; +template<> struct ConfigTagTimeDiscretisation< flowsBuildConfigTag, ImplicitTimeDiscretisationTag >{ enum { enabled = false }; }; + +/**** + * Only the Runge-Kutta-Merson solver is enabled by default. + */ +template<> struct ConfigTagExplicitSolver< flowsBuildConfigTag, ExplicitEulerSolverTag >{ enum { enabled = true }; }; + +} // namespace Solvers + +namespace Meshes { +namespace BuildConfigTags { + +template< int Dimensions > struct GridDimensionTag< flowsBuildConfigTag, Dimensions >{ enum { enabled = true }; }; + +/**** + * Turn off support for float and long double. + */ +template<> struct GridRealTag< flowsBuildConfigTag, float > { enum { enabled = false }; }; +template<> struct GridRealTag< flowsBuildConfigTag, long double > { enum { enabled = false }; }; + +/**** + * Turn off support for short int and long int indexing. + */ +template<> struct GridIndexTag< flowsBuildConfigTag, short int >{ enum { enabled = false }; }; +template<> struct GridIndexTag< flowsBuildConfigTag, long int >{ enum { enabled = false }; }; + +} // namespace BuildConfigTags +} // namespace Meshes +} // namespace TNL + +#endif /* FLOWSBUILDCONFIGTAG_H_ */ diff --git a/src/Examples/turbulent-flows/zero-equation-model/flowsRhs.h b/src/Examples/turbulent-flows/zero-equation-model/flowsRhs.h new file mode 100644 index 000000000..e0b8c7fac --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/flowsRhs.h @@ -0,0 +1,35 @@ +#ifndef FLOWSRHS_H_ +#define FLOWSRHS_H_ + +#include + +namespace TNL { + +template< typename Mesh, typename Real >class flowsRhs + : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > + { + public: + + typedef Mesh MeshType; + typedef Real RealType; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ) + { + return true; + } + + template< typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshEntity& entity, + const Real& time = 0.0 ) const + { +// typedef typename MeshEntity::MeshType::PointType PointType; +// PointType v = entity.getCenter(); + return 0.0; + } +}; + +} //namespace TNL + +#endif /* FLOWSRHS_H_ */ diff --git a/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model b/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model new file mode 100644 index 000000000..cd0c1bbb1 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-euler-navier-stokes + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --differential-operator Steger-Warming \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-AUSM-plus b/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-AUSM-plus new file mode 100644 index 000000000..faaad26b4 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-AUSM-plus @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Ausm-Plus + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Lax-Friedrichs b/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Lax-Friedrichs new file mode 100644 index 000000000..5f7bfbdc6 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Lax-Friedrichs @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Lax-Friedrichs + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Steger-Warming b/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Steger-Warming new file mode 100644 index 000000000..1c3b5ba65 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Steger-Warming @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Steger-Warming + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Van-Leer b/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Van-Leer new file mode 100644 index 000000000..1c3b5ba65 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/run-zero-equation-turbulence-model-Van-Leer @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +tnl-grid-setup --dimensions 2 \ + --origin-x 0.0 \ + --origin-y 0.0 \ + --proportions-x 1.0 \ + --proportions-y 1.0 \ + --size-x 100 \ + --size-y 100 + +tnl-navier-stokes-Steger-Warming + --initial-condition riemann-problem \ + --time-discretisation explicit \ + --boundary-conditions-type cavity \ + --boundary-conditions-constant 0 \ + --operator-right-hand-side Navier-Stokes \ + --discrete-solver euler \ + --time-step 2e-6 \ + --snapshot-period 2e-4 \ + --convergence-residue 0.0 \ + --final-time 2e-2 \ + --initial none \ + --speed-increment 0.05 \ + --inviscid-operators-dynamical-viscosity 1.0 \ + --SED-pressure 10000 \ + --SWD-pressure 10000 \ + --NED-pressure 10000 \ + --NWD-pressure 10000 \ + --SED-velocity-0 0 \ + --SWD-velocity-0 0 \ + --NED-velocity-0 0 \ + --NWD-velocity-0 0 \ + --SED-velocity-1 0 \ + --SWD-velocity-1 0 \ + --NED-velocity-1 0 \ + --NWD-velocity-1 0 \ + --cavity-speed 2.0 + +tnl-view --mesh mesh.tnl --input-files *tnl diff --git a/src/Examples/turbulent-flows/zero-equation-model/turbulentViscosityGetter.h b/src/Examples/turbulent-flows/zero-equation-model/turbulentViscosityGetter.h new file mode 100644 index 000000000..950d56c26 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/turbulentViscosityGetter.h @@ -0,0 +1,299 @@ +/*************************************************************************** + TurbulentViscosityGetter.h - description + ------------------- + begin : Feb 17, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + + +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace TNL { + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class TurbulentViscosityGetterBase : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > +{ + public: + + typedef Real RealType; + typedef Index IndexType; + typedef Mesh MeshType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::CoordinatesType CoordinatesType; + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + static const int Dimensions = MeshType::getMeshDimension(); + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + + TurbulentViscosityGetterBase( MeshFunctionPointer density, + VelocityFieldPointer velocity, + const RealType& mixingLength ) + : density( density ), velocity( velocity ), mixingLength( mixingLength ) {} + + static String getType() + { + return String( "TurbulentViscosityGetter< " ) + + MeshType::getType() + ", " + + TNL::getType< Real >() + ", " + + TNL::getType< Index >() + " >"; + } + + protected: + const MeshFunctionPointer density; + + const VelocityFieldPointer velocity; + + const RealType mixingLength; + + + +}; + +template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class TurbulentViscosityGetter +{ +}; + + + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class TurbulentViscosityGetter< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > + : public TurbulentViscosityGetterBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef TurbulentViscosityGetterBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename MeshEntity > + __cuda_callable__ + Real operator()( const MeshEntity& entity, + const RealType& time = 0.0 ) const + { + return 0; + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class TurbulentViscosityGetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > + : public TurbulentViscosityGetterBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef TurbulentViscosityGetterBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + const typename EntityType::template NeighborEntities< 2 >& neighborEntities = meshEntity.getNeighborEntities(); + const RealType rho = this->density.template getData< DeviceType >()( meshEntity ); + const RealType& hxInverse = meshEntity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = meshEntity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + + return rho * this->mixingLength * this->mixingLength * + (-1.0) * + ( ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 + - ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 + ) + * + ( ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 + - ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class TurbulentViscosityGetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > + : public TurbulentViscosityGetterBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef TurbulentViscosityGetterBase< MeshType, Real, Index > BaseType; + + using typename BaseType::RealType; + using typename BaseType::IndexType; + using typename BaseType::DeviceType; + using typename BaseType::CoordinatesType; + using typename BaseType::MeshFunctionType; + using typename BaseType::VelocityFieldType; + using typename BaseType::VelocityFieldPointer; + using BaseType::Dimensions; + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + const typename EntityType::template NeighborEntities< 3 >& neighborEntities = meshEntity.getNeighborEntities(); + const RealType rho = this->density.template getData< DeviceType >()( meshEntity ); + + const RealType& hxInverse = meshEntity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = meshEntity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + + return rho * this->mixingLength * this->mixingLength * + ( ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 + - ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 + ) + * + ( ( velocity_z_north - velocity_z_south ) * hyInverse * 0.5 + - ( velocity_y_up - velocity_y_down ) * hzInverse * 0.5 + ) + * + ( ( velocity_x_up - velocity_x_down ) * hzInverse * 0.5 + - ( velocity_z_east - velocity_z_west ) * hxInverse * 0.5 + ) + + + ( ( velocity_z_east - velocity_z_west ) * hxInverse * 0.5 + - ( velocity_x_up - velocity_x_down ) * hzInverse * 0.5 + ) + * + ( ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 + - ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 + ) + * + ( ( velocity_y_up - velocity_y_down ) * hzInverse * 0.5 + - ( velocity_z_north - velocity_z_south ) *hyInverse * 0.5 + ); + } + + /*template< typename MeshEntity > + __cuda_callable__ + Index getLinearSystemRowLength( const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity ) const; + + template< typename MeshEntity, typename Vector, typename MatrixRow > + __cuda_callable__ + void updateLinearSystem( const RealType& time, + const RealType& tau, + const MeshType& mesh, + const IndexType& index, + const MeshEntity& entity, + const MeshFunctionType& u, + Vector& b, + MatrixRow& matrixRow ) const;*/ +}; + + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.cpp b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.cpp new file mode 100644 index 000000000..338a9f059 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.cpp @@ -0,0 +1 @@ +#include "zeroEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.cu b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.cu new file mode 100644 index 000000000..338a9f059 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.cu @@ -0,0 +1 @@ +#include "zeroEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.h new file mode 100644 index 000000000..aaf4f729b --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModel.h @@ -0,0 +1,276 @@ +#include +#include +#include +#include +#include +#include "zeroEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h" +#include "DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h" +#include "DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h" +#include "DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class zeroEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< String >( "differential-operator", "Choose the differential operator.", "Lax-Friedrichs"); + config.addEntryEnum< String >( "Lax-Friedrichs" ); + config.addEntryEnum< String >( "Steger-Warming" ); + config.addEntryEnum< String >( "VanLeer" ); + config.addEntryEnum< String >( "AUSMPlus" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class zeroEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef PrandtlRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + String differentialOperatorType = parameters.getParameter< String >( "differential-operator"); + if( differentialOperatorType == "Lax-Friedrichs" ) + { + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "Steger-Warming" ) + { + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "VanLeer" ) + { + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + if( differentialOperatorType == "AUSMPlus" ) + { + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + } + + + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< zeroEquationTurbulenceModelSetter, zeroEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.cpp b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.cpp new file mode 100644 index 000000000..5863b3135 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.cpp @@ -0,0 +1 @@ +#include "zeroEquationTurbulenceModelAUSMPlus.h" diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.cu b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.cu new file mode 100644 index 000000000..5863b3135 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.cu @@ -0,0 +1 @@ +#include "zeroEquationTurbulenceModelAUSMPlus.h" diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.h new file mode 100644 index 000000000..ea02ee501 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.h @@ -0,0 +1,138 @@ +//#include +#include +#include +#include +#include +#include +#include "zeroEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlus.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class zeroEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + AUSMPlus< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class zeroEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef PrandtlOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef AUSMPlus< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< zeroEquationTurbulenceModelSetter, zeroEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.cpp b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.cpp new file mode 100644 index 000000000..4104390fe --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.cpp @@ -0,0 +1 @@ +#include "zeroEquationTurbulenceModelLaxFriedrichs.h" diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.cu b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.cu new file mode 100644 index 000000000..4104390fe --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.cu @@ -0,0 +1 @@ +#include "zeroEquationTurbulenceModelLaxFriedrichs.h" diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.h new file mode 100644 index 000000000..2949183a4 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.h @@ -0,0 +1,139 @@ +//#include +#include +#include +#include +#include +#include +#include "zeroEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Navier-Stokes/Lax-Friedrichs/LaxFridrichs.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class zeroEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class zeroEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + String operatorRightHandSideType = parameters.getParameter< String >( "operator-right-hand-side"); + typedef PrandtlOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< zeroEquationTurbulenceModelSetter, zeroEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem.h new file mode 100644 index 000000000..7acc686bc --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem.h @@ -0,0 +1,140 @@ +/*************************************************************************** + zeroEquationTurbulenceModelProblem.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include "CompressibleConservativeVariables.h" + + +using namespace TNL::Problems; + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +class zeroEquationTurbulenceModelProblem: + public PDEProblem< Mesh, + Communicator, + typename InviscidOperators::RealType, + typename Mesh::DeviceType, + typename InviscidOperators::IndexType > +{ + public: + + typedef typename InviscidOperators::RealType RealType; + typedef typename Mesh::DeviceType DeviceType; + typedef typename InviscidOperators::IndexType IndexType; + typedef PDEProblem< Mesh, Communicator, RealType, DeviceType, IndexType > BaseType; + + typedef Communicator CommunicatorType; + + using typename BaseType::MeshType; + using typename BaseType::MeshPointer; + using typename BaseType::DofVectorType; + using typename BaseType::DofVectorPointer; + static const int Dimensions = Mesh::getMeshDimension(); + + typedef Functions::MeshFunction< Mesh > MeshFunctionType; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< MeshFunctionType, DeviceType > MeshFunctionPointer; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + typedef Pointers::SharedPointer< InviscidOperators > InviscidOperatorsPointer; + typedef Pointers::SharedPointer< BoundaryCondition > BoundaryConditionPointer; + typedef Pointers::SharedPointer< RightHandSide, DeviceType > RightHandSidePointer; + + static String getType(); + + String getPrologHeader() const; + + void writeProlog( Logger& logger, + const Config::ParameterContainer& parameters ) const; + + bool setup( const Config::ParameterContainer& parameters, + const String& prefix = "" ); + + bool setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ); + + template< typename Matrix > + bool setupLinearSystem( Matrix& matrix ); + + bool makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ); + + IndexType getDofs() const; + + void bindDofs( DofVectorPointer& dofs ); + + void getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ); + + + void applyBoundaryConditions( const RealType& time, + DofVectorPointer& dofs ); + + template< typename Matrix > + void assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs, + Matrix& matrix, + DofVectorPointer& rightHandSide ); + + bool postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ); + + protected: + + InviscidOperatorsPointer inviscidOperatorsPointer; + + BoundaryConditionPointer boundaryConditionPointer; + RightHandSidePointer rightHandSidePointer; + + ConservativeVariablesPointer conservativeVariables, + conservativeVariablesRHS; + + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::ContinuityOperatorType, typename BoundaryCondition::DensityBoundaryConditionsType, RightHandSide > explicitUpdaterContinuity; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumXOperatorType, typename BoundaryCondition::MomentumXBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumX; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumYOperatorType, typename BoundaryCondition::MomentumYBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumY; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::MomentumZOperatorType, typename BoundaryCondition::MomentumZBoundaryConditionsType, RightHandSide > explicitUpdaterMomentumZ; + Solvers::PDE::ExplicitUpdater< Mesh, MeshFunctionType, typename InviscidOperators::EnergyOperatorType, typename BoundaryCondition::EnergyBoundaryConditionsType, RightHandSide > explicitUpdaterEnergy; + + + VelocityFieldPointer velocity; + MeshFunctionPointer pressure; + MeshFunctionPointer turbulentViscosity; + + RealType gamma; + RealType speedIncrement; + RealType cavitySpeed; + RealType speedIncrementUntil; + RealType finalSpeed; + RealType startSpeed; + RealType speedIncrementUntilHThrottle; + RealType finalSpeedHThrottle; + RealType startSpeedHThrottle; + RealType mixingLength; +}; + +} // namespace TNL + +#include "zeroEquationTurbulenceModelProblem_impl.h" + diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h new file mode 100644 index 000000000..16f821393 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h @@ -0,0 +1,507 @@ +/*************************************************************************** + zeroEquationTurbulenceModelProblem_impl.h - description + ------------------- + begin : Feb 13, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "RiemannProblemInitialCondition.h" +#include "CompressibleConservativeVariables.h" +#include "PhysicalVariablesGetter.h" +#include "zeroEquationTurbulenceModelProblem.h" + +namespace TNL { + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getType() +{ + return String( "zeroEquationTurbulenceModelProblem< " ) + Mesh :: getType() + " >"; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +String +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getPrologHeader() const +{ + return String( "flow solver" ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +writeProlog( Logger& logger, const Config::ParameterContainer& parameters ) const +{ + /**** + * Add data you want to have in the computation report (log) as follows: + * logger.writeParameter< double >( "Parameter description", parameter ); + */ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setup( const Config::ParameterContainer& parameters, + const String& prefix ) +{ + if( ! this->inviscidOperatorsPointer->setup( this->getMesh(), parameters, prefix + "inviscid-operators-" ) || + ! this->boundaryConditionPointer->setup( this->getMesh(), parameters, prefix + "boundary-conditions-" ) || + ! this->rightHandSidePointer->setup( parameters, prefix + "right-hand-side-" ) ) + return false; + this->gamma = parameters.getParameter< double >( "gamma" ); + this->startSpeed = parameters.getParameter< double >( "start-speed" ); + this->finalSpeed = parameters.getParameter< double >( "final-speed" ); + this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); + this->startSpeedHThrottle = parameters.getParameter< double >( "start-speed-h-throttle" ); + this->finalSpeedHThrottle = parameters.getParameter< double >( "final-speed-h-throttle" ); + this->speedIncrementUntilHThrottle = parameters.getParameter< RealType >( "speed-increment-until-h-throttle" ); + this->mixingLength = parameters.getParameter< RealType >( "mixing-length" ); + velocity->setMesh( this->getMesh() ); + pressure->setMesh( this->getMesh() ); + + /**** + * Set-up operators + */ + + this->inviscidOperatorsPointer->setVelocity( this->velocity ); + this->inviscidOperatorsPointer->setPressure( this->pressure ); + this->inviscidOperatorsPointer->setDensity( this->conservativeVariables->getDensity() ); + this->inviscidOperatorsPointer->setGamma( this->gamma ); + this->inviscidOperatorsPointer->setTurbulentViscosity(this->turbulentViscosity); + + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.setDifferentialOperator( this->inviscidOperatorsPointer->getContinuityOperator() ); + this->explicitUpdaterContinuity.setBoundaryConditions( this->boundaryConditionPointer->getDensityBoundaryCondition() ); + this->explicitUpdaterContinuity.setRightHandSide( this->rightHandSidePointer ); + + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumXOperator() ); + this->explicitUpdaterMomentumX.setBoundaryConditions( this->boundaryConditionPointer->getMomentumXBoundaryCondition() ); + this->explicitUpdaterMomentumX.setRightHandSide( this->rightHandSidePointer ); + + if( Dimensions > 1 ) + { + this->explicitUpdaterMomentumY.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumYOperator() ); + this->explicitUpdaterMomentumY.setBoundaryConditions( this->boundaryConditionPointer->getMomentumYBoundaryCondition() ); + this->explicitUpdaterMomentumY.setRightHandSide( this->rightHandSidePointer ); + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.setDifferentialOperator( this->inviscidOperatorsPointer->getMomentumZOperator() ); + this->explicitUpdaterMomentumZ.setBoundaryConditions( this->boundaryConditionPointer->getMomentumZBoundaryCondition() ); + this->explicitUpdaterMomentumZ.setRightHandSide( this->rightHandSidePointer ); + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.setDifferentialOperator( this->inviscidOperatorsPointer->getEnergyOperator() ); + this->explicitUpdaterEnergy.setBoundaryConditions( this->boundaryConditionPointer->getEnergyBoundaryCondition() ); + this->explicitUpdaterEnergy.setRightHandSide( this->rightHandSidePointer ); + + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +typename zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >::IndexType +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getDofs() const +{ + /**** + * Return number of DOFs (degrees of freedom) i.e. number + * of unknowns to be resolved by the main solver. + */ + return this->conservativeVariables->getDofs( this->getMesh() ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +bindDofs( DofVectorPointer& dofVector ) +{ + this->conservativeVariables->bind( this->getMesh(), dofVector ); +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setInitialCondition( const Config::ParameterContainer& parameters, + DofVectorPointer& dofs ) +{ + CompressibleConservativeVariables< MeshType > conservativeVariables; + conservativeVariables.bind( this->getMesh(), dofs ); + const String& initialConditionType = parameters.getParameter< String >( "initial-condition" ); + this->speedIncrementUntil = parameters.getParameter< RealType >( "speed-increment-until" ); + this->speedIncrement = parameters.getParameter< RealType >( "speed-increment" ); + this->cavitySpeed = parameters.getParameter< RealType >( "cavity-speed" ); + if( initialConditionType == "riemann-problem" ) + { + RiemannProblemInitialCondition< MeshType > initialCondition; + if( ! initialCondition.setup( parameters ) ) + return false; + initialCondition.setInitialCondition( conservativeVariables ); + return true; + } + std::cerr << "Unknown initial condition " << initialConditionType << std::endl; + return false; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +bool +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +setupLinearSystem( Matrix& matrix ) +{ +/* const IndexType dofs = this->getDofs(); + typedef typename Matrix::CompressedRowLengthsVector CompressedRowLengthsVectorType; + CompressedRowLengthsVectorType rowLengths; + if( ! rowLengths.setSize( dofs ) ) + return false; + MatrixSetter< MeshType, DifferentialOperator, BoundaryCondition, CompressedRowLengthsVectorType > matrixSetter; + matrixSetter.template getCompressedRowLengths< typename Mesh::Cell >( mesh, + differentialOperator, + boundaryCondition, + rowLengths ); + matrix.setDimensions( dofs, dofs ); + if( ! matrix.setCompressedRowLengths( rowLengths ) ) + return false;*/ + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +makeSnapshot( const RealType& time, + const IndexType& step, + DofVectorPointer& dofs ) +{ + std::cout << std::endl << "Writing output at time " << time << " step " << step << "." << std::endl; + + this->bindDofs( dofs ); + PhysicalVariablesGetter< MeshType > physicalVariablesGetter; + physicalVariablesGetter.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariablesGetter.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + + FileName fileName; + fileName.setExtension( "tnl" ); + fileName.setIndex( step ); + fileName.setFileNameBase( "density-" ); +// if( ! this->conservativeVariables->getDensity()->save( fileName.getFileName() ) ) + this->conservativeVariables->getDensity()->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "velocity-" ); +// if( ! this->velocity->save( fileName.getFileName() ) ) + this->velocity->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "pressure-" ); +// if( ! this->pressure->save( fileName.getFileName() ) ) + this->pressure->save( fileName.getFileName() ); +// return false; + + fileName.setFileNameBase( "energy-" ); +// if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) + this->conservativeVariables->getEnergy()->save( fileName.getFileName() ); +// return false; + return true; +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +getExplicitUpdate( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + DofVectorPointer& _fu ) +{ + typedef typename MeshType::Cell Cell; + + /**** + * Bind DOFs + */ + this->conservativeVariables->bind( this->getMesh(), _u ); + this->conservativeVariablesRHS->bind( this->getMesh(), _fu ); + + /**** + * Resolve the physical variables + */ + PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; + physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); + physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); + physicalVariables.getTurbulentViscocsity( this->conservativeVariables, this->velocity, this->mixingLength, this->turbulentViscosity ); + + /**** + * Set-up operators + */ + + this->inviscidOperatorsPointer->setTau( tau ); + + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getDensity(), + this->conservativeVariablesRHS->getDensity() ); + +// this->explicitUpdaterContinuity.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, +// this->conservativeVariables->getDensity() ); + + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 0 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 0 ] ); //, fuRhoVelocityX ); + if( Dimensions > 1 ) + { + this->explicitUpdaterMomentumY.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 1 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 1 ] ); //, fuRhoVelocityX ); + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, + ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.template update< typename Mesh::Cell, Communicator >( time, tau, this->getMesh(), + this->conservativeVariables->getEnergy(), // uRhoVelocityX, + this->conservativeVariablesRHS->getEnergy() ); //, fuRhoVelocityX ); + + /*this->conservativeVariablesRHS->getDensity()->write( "density", "gnuplot" ); + this->conservativeVariablesRHS->getEnergy()->write( "energy", "gnuplot" ); + this->conservativeVariablesRHS->getMomentum()->write( "momentum", "gnuplot", 0.05 ); + getchar();*/ + +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +void +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +applyBoundaryConditions( const RealType& time, + DofVectorPointer& dofs ) +{ + /**** + * Update Boundary Conditions + */ + if(this->speedIncrementUntil > time ) + { + this->boundaryConditionPointer->setTimestep(this->speedIncrement); + } + else + { + this->boundaryConditionPointer->setTimestep(0); + } + this->boundaryConditionPointer->setSpeed(this->cavitySpeed); + this->boundaryConditionPointer->setCompressibleConservativeVariables(this->conservativeVariables); + this->boundaryConditionPointer->setGamma(this->gamma); + this->boundaryConditionPointer->setPressure(this->pressure); + this->boundaryConditionPointer->setVerticalThrottleSpeed( startSpeed, finalSpeed, time, speedIncrementUntil ); + this->boundaryConditionPointer->setHorizontalThrottleSpeed( startSpeedHThrottle, finalSpeedHThrottle, time, speedIncrementUntilHThrottle ); + /**** + * Bind DOFs + */ + this->conservativeVariables->bind( this->getMesh(), dofs ); +// this->conservativeVariables->getDensity()->write( "density", "gnuplot" ); +// this->conservativeVariables->getEnergy()->write( "energy", "gnuplot" ); +// this->conservativeVariables->getMomentum()->write( "momentum", "gnuplot", 0.05 ); +// dofs->save("dofs.tnl"); +// getchar(); +// std::cout <<"applyBCC" << std::endl; + /**** + * Continuity equation + */ + this->explicitUpdaterContinuity.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getDensity() ); + /**** + * Momentum equations + */ + this->explicitUpdaterMomentumX.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 0 ] ); // uRhoVelocityX, + if( Dimensions > 1 ) + { + + this->explicitUpdaterMomentumY.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 1 ] ); // uRhoVelocityX, + } + + if( Dimensions > 2 ) + { + this->explicitUpdaterMomentumZ.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + ( *this->conservativeVariables->getMomentum() )[ 2 ] ); // uRhoVelocityX, + } + + /**** + * Energy equation + */ + this->explicitUpdaterEnergy.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, + this->conservativeVariables->getEnergy() ); // uRhoVelocityX, +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > + template< typename Matrix > +void +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +assemblyLinearSystem( const RealType& time, + const RealType& tau, + DofVectorPointer& _u, + Matrix& matrix, + DofVectorPointer& b ) +{ +/* LinearSystemAssembler< Mesh, + MeshFunctionType, + InviscidOperators, + BoundaryCondition, + RightHandSide, + BackwardTimeDiscretisation, + Matrix, + DofVectorType > systemAssembler; + + MeshFunction< Mesh > u( mesh, _u ); + systemAssembler.template assembly< typename Mesh::Cell >( time, + tau, + this->differentialOperator, + this->boundaryCondition, + this->rightHandSide, + u, + matrix, + b );*/ +} + +template< typename Mesh, + typename BoundaryCondition, + typename RightHandSide, + typename Communicator, + typename InviscidOperators > +bool +zeroEquationTurbulenceModelProblem< Mesh, BoundaryCondition, RightHandSide, Communicator, InviscidOperators >:: +postIterate( const RealType& time, + const RealType& tau, + DofVectorPointer& dofs ) +{ + /* + typedef typename MeshType::Cell Cell; + int count = mesh->template getEntitiesCount< Cell >()/4; + //bind _u + this->_uRho.bind( *dofs, 0, count); + this->_uRhoVelocityX.bind( *dofs, count, count); + this->_uRhoVelocityY.bind( *dofs, 2 * count, count); + this->_uEnergy.bind( *dofs, 3 * count, count); + + MeshFunctionType velocity( mesh, this->velocity ); + MeshFunctionType velocityX( mesh, this->velocityX ); + MeshFunctionType velocityY( mesh, this->velocityY ); + MeshFunctionType pressure( mesh, this->pressure ); + MeshFunctionType uRho( mesh, _uRho ); + MeshFunctionType uRhoVelocityX( mesh, _uRhoVelocityX ); + MeshFunctionType uRhoVelocityY( mesh, _uRhoVelocityY ); + MeshFunctionType uEnergy( mesh, _uEnergy ); + //Generating differential operators + Velocity euler2DVelocity; + VelocityX euler2DVelocityX; + VelocityY euler2DVelocityY; + Pressure euler2DPressure; + + //velocityX + euler2DVelocityX.setRhoVelX(uRhoVelocityX); + euler2DVelocityX.setRho(uRho); +// OperatorFunction< VelocityX, MeshFunction, void, true > OFVelocityX; +// velocityX = OFVelocityX; + + //velocityY + euler2DVelocityY.setRhoVelY(uRhoVelocityY); + euler2DVelocityY.setRho(uRho); +// OperatorFunction< VelocityY, MeshFunction, void, time > OFVelocityY; +// velocityY = OFVelocityY; + + //velocity + euler2DVelocity.setVelX(velocityX); + euler2DVelocity.setVelY(velocityY); +// OperatorFunction< Velocity, MeshFunction, void, time > OFVelocity; +// velocity = OFVelocity; + + //pressure + euler2DPressure.setGamma(gamma); + euler2DPressure.setVelocity(velocity); + euler2DPressure.setEnergy(uEnergy); + euler2DPressure.setRho(uRho); +// OperatorFunction< euler2DPressure, MeshFunction, void, time > OFPressure; +// pressure = OFPressure; + */ + return true; +} + +} // namespace TNL + diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.cpp b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.cpp new file mode 100644 index 000000000..da6b355f9 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.cpp @@ -0,0 +1 @@ +#include "zeroEquationTurbulenceModelStegerWarming.h" diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.cu b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.cu new file mode 100644 index 000000000..bce6dd559 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.cu @@ -0,0 +1 @@ +#include "navierStokesStegerWarming.h" diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.h new file mode 100644 index 000000000..3dfbd1640 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.h @@ -0,0 +1,138 @@ +//#include +#include +#include +#include +#include +#include +#include "zeroEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Navier-Stokes/Steger-Warming/StegerWarming.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class zeroEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + StegerWarming< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class zeroEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef PrandtlOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef StegerWarming< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< zeroEquationTurbulenceModelSetter, zeroEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.cpp b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.cpp new file mode 100644 index 000000000..13b56c8fc --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.cpp @@ -0,0 +1 @@ +#include "zeroEquationTurbulenceModelVanLeer.h" diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.cu b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.cu new file mode 100644 index 000000000..338a9f059 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.cu @@ -0,0 +1 @@ +#include "zeroEquationTurbulenceModel.h" diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.h new file mode 100644 index 000000000..9d8705849 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.h @@ -0,0 +1,141 @@ +//#include +#include +#include +#include +#include +#include +#include "zeroEquationTurbulenceModelProblem.h" +#include "DifferentialOperators/Navier-Stokes/VanLeer/VanLeer.h" +#include "flowsRhs.h" +#include "flowsBuildConfigTag.h" + +#include "RiemannProblemInitialCondition.h" +#include "BoundaryConditions/Cavity/BoundaryConditionsCavity.h" +#include "BoundaryConditions/Boiler/BoundaryConditionsBoiler.h" +#include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" +#include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" +#include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" +#include "DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlOperatorRightHandSide.h" + +using namespace TNL; + +typedef flowsBuildConfigTag BuildConfig; + +/**** + * Uncomment the following (and comment the previous line) for the complete build. + * This will include support for all floating point precisions, all indexing types + * and more solvers. You may then choose between them from the command line. + * The compile time may, however, take tens of minutes or even several hours, + * especially if CUDA is enabled. Use this, if you want, only for the final build, + * not in the development phase. + */ +//typedef tnlDefaultConfigTag BuildConfig; + +template< typename ConfigTag >class zeroEquationTurbulenceModelConfig +{ + public: + static void configSetup( Config::ConfigDescription & config ) + { + config.addDelimiter( "Inviscid flow settings:" ); + config.addEntry< String >( "boundary-conditions-type", "Choose the boundary conditions type.", "cavity"); + config.addEntryEnum< String >( "boiler" ); + config.addEntryEnum< String >( "boiler-model" ); + config.addEntryEnum< String >( "cavity" ); + config.addEntryEnum< String >( "dirichlet" ); + config.addEntryEnum< String >( "neumann" ); + config.addEntry< String >( "operator-right-hand-side", "Choose equation type.", "Euler"); + config.addEntryEnum< String >( "Euler" ); + config.addEntryEnum< String >( "Navier-Stokes" ); + config.addEntry< double >( "boundary-conditions-constant", "This sets a value in case of the constant boundary conditions." ); + config.addEntry< double >( "speed-increment", "This sets increment of input speed.", 0.0 ); + config.addEntry< double >( "speed-increment-until", "This sets time until input speed will rose", -0.1 ); + config.addEntry< double >( "start-speed", "This sets throttle speed at begining", 0.0 ); + config.addEntry< double >( "final-speed", "This sets speed at destined time", 0.0 ); + config.addEntry< double >( "speed-increment-until-h-throttle", "This sets time until input speed will rose for horizontal throttle", -0.1 ); + config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); + config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); + config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + typedef Meshes::Grid< 3 > Mesh; + VanLeer< Mesh >::configSetup( config, "inviscid-operators-" ); + RiemannProblemInitialCondition< Mesh >::configSetup( config ); + typedef Functions::Analytic::Constant< 3, double > Constant; + BoundaryConditionsBoilerModel< Mesh, Constant >::configSetup( config, "boundary-conditions-" ); + /**** + * Add definition of your solver command line arguments. + */ + + } +}; + +template< typename Real, + typename Device, + typename Index, + typename MeshType, + typename ConfigTag, + typename SolverStarter, + typename CommunicatorType > +class zeroEquationTurbulenceModelSetter +{ + public: + + typedef Real RealType; + typedef Device DeviceType; + typedef Index IndexType; + + static bool run( const Config::ParameterContainer & parameters ) + { + enum { Dimension = MeshType::getMeshDimension() }; + + typedef flowsRhs< MeshType, Real > RightHandSide; + typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; + typedef PrandtlOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; + typedef VanLeer< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; + typedef Functions::Analytic::Constant< Dimension, Real > Constant; + String boundaryConditionsType = parameters.getParameter< String >( "boundary-conditions-type" ); + if( boundaryConditionsType == "cavity" ) + { + typedef BoundaryConditionsCavity< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler" ) + { + typedef BoundaryConditionsBoiler< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "boiler-model" ) + { + typedef BoundaryConditionsBoilerModel< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + typedef Functions::MeshFunction< MeshType > MeshFunction; + if( boundaryConditionsType == "dirichlet" ) + { + typedef BoundaryConditionsDirichlet< MeshType, Constant, MeshType::getMeshDimension(), Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator> Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + if( boundaryConditionsType == "neumann" ) + { + typedef BoundaryConditionsNeumann< MeshType, Constant, Real, Index > BoundaryConditions; + typedef zeroEquationTurbulenceModelProblem< MeshType, BoundaryConditions, RightHandSide, CommunicatorType, ApproximateOperator > Problem; + SolverStarter solverStarter; + return solverStarter.template run< Problem >( parameters ); + } + return true;} + +}; + +int main( int argc, char* argv[] ) +{ + Solvers::Solver< zeroEquationTurbulenceModelSetter, zeroEquationTurbulenceModelConfig, BuildConfig > solver; + if( ! solver. run( argc, argv ) ) + return EXIT_FAILURE; + return EXIT_SUCCESS; +}; -- GitLab From a0f9de1b9c69382643c379506d4ecee01e41b1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Sat, 20 Apr 2019 18:58:27 +0200 Subject: [PATCH 22/28] minor changes --- .../DisipationBoundaryConditionBoiler.h | 27 ++++-------- .../DisipationBoundaryConditionBoilerModel.h | 41 +++++++------------ .../DisipationBoundaryConditionCavity.h | 11 ++--- .../KOmega-model/PhysicalVariablesGetter.h | 23 ++++------- .../RiemannProblemInitialCondition.h | 32 +++++++-------- .../twoEquationTurbulenceModelProblem_impl.h | 2 +- 6 files changed, 52 insertions(+), 84 deletions(-) diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h index a94af83b6..4ddfd0d61 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Boiler/DisipationBoundaryConditionBoiler.h @@ -129,8 +129,7 @@ class DisipationBoundaryConditionsBoiler< Meshes::Grid< 1, MeshReal, Device, Mes const auto& neighborEntities = entity.getNeighborEntities(); const IndexType& index = entity.getIndex(); if( entity.getCoordinates().x() == 0 ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) / this->lengthScale; else return u[ neighborEntities.template getEntityIndex< -1 >() ]; @@ -279,8 +278,7 @@ class DisipationBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, Mes if( entity.getCoordinates().x() == 0 ) { if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) / this->lengthScale; else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; @@ -304,8 +302,7 @@ class DisipationBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, Mes if( entity.getCoordinates().x() == entity.getMesh().getDimensions().x() - 1 ) { if( ( entity.getCoordinates().y() < 0.20 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.19 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) / this->lengthScale; else if( entity.getCoordinates().y() > 0.8 * ( entity.getMesh().getDimensions().y() - 1 ) && false ) return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; @@ -330,8 +327,7 @@ class DisipationBoundaryConditionsBoiler< Meshes::Grid< 2, MeshReal, Device, Mes if( entity.getCoordinates().y() == 0 ) { if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.4 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) / this->lengthScale; else return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; @@ -527,8 +523,7 @@ class DisipationBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, Mes { if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) / this->lengthScale; else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; @@ -537,8 +532,7 @@ class DisipationBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, Mes { if( ( entity.getCoordinates().y() < 0.59 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.39 * ( entity.getMesh().getDimensions().y() - 1 ) ) &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) / this->lengthScale; else if( entity.getCoordinates().y() >0.8 * ( entity.getMesh().getDimensions().y() - 1 ) ) return u[ neighborEntities.template getEntityIndex< -1, 0, 0 >() ]; @@ -549,8 +543,7 @@ class DisipationBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, Mes { if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) / this->lengthScale; else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; @@ -559,8 +552,7 @@ class DisipationBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, Mes { if( ( entity.getCoordinates().x() < 0.59 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.39 * ( entity.getMesh().getDimensions().x() - 1 ) ) &&( entity.getCoordinates().z() < 0.59 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.39 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) / this->lengthScale; else return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; @@ -569,8 +561,7 @@ class DisipationBoundaryConditionsBoiler< Meshes::Grid< 3, MeshReal, Device, Mes { if( ( entity.getCoordinates().x() < 0.6 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.4 * ( entity.getMesh().getDimensions().y() - 1 ) ) &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) / this->lengthScale; else diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h index b3f585a9e..a112001cc 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/DisipationBoundaryConditionBoilerModel.h @@ -129,8 +129,7 @@ class DisipationBoundaryConditionsBoilerModel< Meshes::Grid< 1, MeshReal, Device const auto& neighborEntities = entity.getNeighborEntities(); const IndexType& index = entity.getIndex(); if( entity.getCoordinates().x() == 0 ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ) ) / this->lengthScale; else return u[ neighborEntities.template getEntityIndex< -1 >() ]; @@ -337,8 +336,7 @@ class DisipationBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device ) // throttle Disipation { - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ) ) / this->lengthScale; } return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; @@ -385,8 +383,7 @@ class DisipationBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device ) // throttle Disipation { - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ) ) / this->lengthScale; } // if for chimney exit @@ -397,7 +394,8 @@ class DisipationBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device if( ( entity.getCoordinates().x() < 0.592 * ( entity.getMesh().getDimensions().x() - 1 ) ) && ( entity.getCoordinates().x() > 0.408 * ( entity.getMesh().getDimensions().x() - 1 ) ) ) - return 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed; + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed ) ) + / this->lengthScale; return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; } // The following line is commented to avoid compiler warning @@ -619,12 +617,10 @@ const RealType operator()( const MeshFunction& u, // if for y axis { if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ) ) / this->lengthScale; if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ) ) / this->lengthScale; return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; } @@ -673,12 +669,10 @@ const RealType operator()( const MeshFunction& u, // if for y axis { if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ) ) / this->lengthScale; if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ) ) / this->lengthScale; return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; // if for chimney exit @@ -728,12 +722,10 @@ const RealType operator()( const MeshFunction& u, // if for x axis { if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ) ) / this->lengthScale; if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ) ) / this->lengthScale; return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; @@ -783,12 +775,10 @@ const RealType operator()( const MeshFunction& u, // if for x axis { if( entity.getCoordinates().x() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ) ) / this->lengthScale; if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ) ) / this->lengthScale; return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; } @@ -798,9 +788,8 @@ const RealType operator()( const MeshFunction& u, { if( ( entity.getCoordinates().y() < 0.592 * ( entity.getMesh().getDimensions().y() - 1 ) ) && ( entity.getCoordinates().y() > 0.408 * ( entity.getMesh().getDimensions().y() - 1 ) ) ) // &&( entity.getCoordinates().y() < 0.6 * ( entity.getMesh().getDimensions().z() - 1 ) ) && ( entity.getCoordinates().z() > 0.4 * ( entity.getMesh().getDimensions().z() - 1 ) ) ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->horizontalThrottleSpeed * this->horizontalThrottleSpeed ), ( 3.0 / 2.0 ) ) - / this->lengthScale; + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->verticalThrottleSpeed * this->verticalThrottleSpeed ) ) + / this->lengthScale; return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; } return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h index acee185a2..6f15f3f88 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/Cavity/DisipationBoundaryConditionCavity.h @@ -128,8 +128,7 @@ class DisipationBoundaryConditionsCavity< Meshes::Grid< 1, MeshReal, Device, Mes const auto& neighborEntities = entity.getNeighborEntities(); const IndexType& index = entity.getIndex(); if( entity.getCoordinates().x() == 0 ) - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) / this->lengthScale; else return u[ neighborEntities.template getEntityIndex< -1 >() ]; @@ -290,9 +289,8 @@ class DisipationBoundaryConditionsCavity< Meshes::Grid< 2, MeshReal, Device, Mes // The following line is commented to avoid compiler warning //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) { - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) - / this->lengthScale; + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) + / this->lengthScale; } } @@ -469,8 +467,7 @@ class DisipationBoundaryConditionsCavity< Meshes::Grid< 3, MeshReal, Device, Mes // The following line is commented to avoid compiler warning //if( entity.getCoordinates().z() == entity.getMesh().getDimensions().z() - 1 ) { - return this->turbulenceConstant - * std::pow( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ), ( 3.0 / 2.0 ) ) + return std::sqrt( ( 2.0/3.0 * this->intensity * this->intensity * this->cavitySpeed * this->cavitySpeed ) ) / this->lengthScale; } } diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/PhysicalVariablesGetter.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/PhysicalVariablesGetter.h index 452620d0d..1ead03997 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/PhysicalVariablesGetter.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/PhysicalVariablesGetter.h @@ -98,7 +98,7 @@ class PhysicalVariablesGetter typedef typename MeshType::RealType RealType; TurbulentEnergyGetter( MeshFunctionPointer density, - MeshFunctionPointer turbulentEnergyXDensity ) + MeshFunctionPointer turbulentEnergyXDensity ) : density( density ), turbulentEnergyXDensity( turbulentEnergyXDensity ) {} template< typename EntityType > @@ -147,11 +147,9 @@ class PhysicalVariablesGetter public: typedef typename MeshType::RealType RealType; - TurbulentViscosityGetter( MeshFunctionPointer density, - MeshFunctionPointer turbulentEnergy, - RealType turbulenceConstant, + TurbulentViscosityGetter( MeshFunctionPointer turbulentEnergy, MeshFunctionPointer disipation ) - : density( density ), turbulentEnergy( turbulentEnergy ), turbulenceConstant( turbulenceConstant ), disipation( disipation ) {} + :turbulentEnergy( turbulentEnergy ), disipation( disipation ) {} template< typename EntityType > __cuda_callable__ @@ -161,15 +159,12 @@ class PhysicalVariablesGetter if( disipation.template getData< DeviceType >()( meshEntity ) == 0.0 ) return 0; else - return density.template getData< DeviceType >()( meshEntity ) * turbulenceConstant - * turbulentEnergy.template getData< DeviceType >()( meshEntity ) - * turbulentEnergy.template getData< DeviceType >()( meshEntity ) + return turbulentEnergy.template getData< DeviceType >()( meshEntity ) / disipation.template getData< DeviceType >()( meshEntity ); } protected: - const MeshFunctionPointer density, turbulentEnergy, disipation; - const RealType turbulenceConstant; + const MeshFunctionPointer disipation, turbulentEnergy; }; @@ -221,18 +216,14 @@ class PhysicalVariablesGetter } } - void getTurbulentViscosity( const ConservativeVariablesPointer& conservativeVariables, - MeshFunctionPointer& turbulentEnergy_no_rho, + void getTurbulentViscosity( MeshFunctionPointer& turbulentEnergy_no_rho, MeshFunctionPointer& disipation_no_rho, - const RealType& turbulenceConstant, MeshFunctionPointer& turbulentViscosity ) { Functions::MeshFunctionEvaluator< MeshFunctionType, TurbulentViscosityGetter > evaluator; for( int i = 0; i < Dimensions; i++ ) { - Pointers::SharedPointer< TurbulentViscosityGetter, DeviceType > turbulentViscosityGetter( conservativeVariables->getDensity(), - turbulentEnergy_no_rho, - turbulenceConstant, + Pointers::SharedPointer< TurbulentViscosityGetter, DeviceType > turbulentViscosityGetter( turbulentEnergy_no_rho, disipation_no_rho); evaluator.evaluate( turbulentViscosity, turbulentViscosityGetter ); } diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/RiemannProblemInitialCondition.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/RiemannProblemInitialCondition.h index 90a456fb4..e503e5be8 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/RiemannProblemInitialCondition.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/RiemannProblemInitialCondition.h @@ -1287,7 +1287,7 @@ class RiemannProblemInitialCondition this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); this->NWUMomentum = NWUVelocity * NWUDensity; this->NWUTurbulentEnergy = this->NWUDensity * TurbulentEnergy( NWUVelocity, this->intensity); - this->NWUDisipation = this->turbulenceConstant * std::pow( NWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->NWUDisipation = std::sqrt(NWUTurbulentEnergy) / this->lengthScale; this->SWUDensity = parameters.getParameter< RealType >( prefix + "SWU-density" ); this->SWUVelocity.setup( parameters, prefix + "SWU-velocity-" ); @@ -1295,7 +1295,7 @@ class RiemannProblemInitialCondition this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); this->SWUMomentum = SWUVelocity * SWUDensity; this->SWUTurbulentEnergy = SWUDensity * TurbulentEnergy( SWUVelocity, this->intensity); - this->SWUDisipation = this->turbulenceConstant * std::pow( SWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->SWUDisipation = std::sqrt(SWDTurbulentEnergy) / this->lengthScale; this->NWDDensity = parameters.getParameter< RealType >( prefix + "NWD-density" ); this->NWDVelocity.setup( parameters, prefix + "NWD-velocity-" ); @@ -1303,7 +1303,7 @@ class RiemannProblemInitialCondition this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); this->NWDMomentum = NWDVelocity * NWDDensity; this->NWDTurbulentEnergy = NWDDensity * TurbulentEnergy( NWDVelocity, this->intensity); - this->NWDDisipation = this->turbulenceConstant * std::pow( NWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->NWDDisipation = std::sqrt(NWDTurbulentEnergy) / this->lengthScale; this->SWDDensity = parameters.getParameter< RealType >( prefix + "SWD-density" ); this->SWDVelocity.setup( parameters, prefix + "SWD-velocity-" ); @@ -1311,7 +1311,7 @@ class RiemannProblemInitialCondition this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); this->SWDMomentum = SWDVelocity * SWDDensity; this->SWDTurbulentEnergy = SWDDensity * TurbulentEnergy( SWDVelocity, this->intensity); - this->SWDDisipation = this->turbulenceConstant * std::pow( SWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->SWDDisipation = std::sqrt(SWDTurbulentEnergy) / this->lengthScale; this->NEUDensity = parameters.getParameter< RealType >( prefix + "NEU-density" ); this->NEUVelocity.setup( parameters, prefix + "NEU-velocity-" ); @@ -1319,7 +1319,7 @@ class RiemannProblemInitialCondition this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); this->NEUMomentum = NEUVelocity * NEUDensity; this->NEUTurbulentEnergy = NEUDensity * TurbulentEnergy( NEUVelocity, this->intensity); - this->NEUDisipation = this->turbulenceConstant * std::pow( NEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->NEUDisipation = std::sqrt(NEUTurbulentEnergy) / this->lengthScale; this->SEUDensity = parameters.getParameter< RealType >( prefix + "SEU-density" ); this->SEUVelocity.setup( parameters, prefix + "SEU-velocity-" ); @@ -1327,7 +1327,7 @@ class RiemannProblemInitialCondition this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); this->SEUMomentum = SEUVelocity * SEUDensity; this->SEUTurbulentEnergy = SEUDensity * TurbulentEnergy( SEUVelocity, this->intensity); - this->SEUDisipation = this->turbulenceConstant * std::pow( SEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->SEUDisipation = std::sqrt(SEUTurbulentEnergy) / this->lengthScale; this->NEDDensity = parameters.getParameter< RealType >( prefix + "NED-density" ); this->NEDVelocity.setup(parameters, prefix + "NED-velocity-" ); @@ -1335,7 +1335,7 @@ class RiemannProblemInitialCondition this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); this->NEDMomentum = NEDVelocity * NEDDensity; this->NEDTurbulentEnergy = NEDDensity * TurbulentEnergy( NEDVelocity, this->intensity); - this->NEDDisipation = this->turbulenceConstant * std::pow( NEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->NEDDisipation = std::sqrt(NEDTurbulentEnergy) / this->lengthScale; this->SEDDensity = parameters.getParameter< RealType >( prefix + "SED-density" ); this->SEDVelocity.setup( parameters, prefix + "SED-velocity-" ); @@ -1343,7 +1343,7 @@ class RiemannProblemInitialCondition this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); this->SEDMomentum = SEDVelocity * SEDDensity; this->SEDTurbulentEnergy = SEDDensity * TurbulentEnergy( SEDVelocity, this->intensity); - this->SEDDisipation = this->turbulenceConstant * std::pow( SEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->SEDDisipation = std::sqrt(SEDTurbulentEnergy) / this->lengthScale; } if(initial == prefix + "1D_2") predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, @@ -1644,7 +1644,7 @@ class RiemannProblemInitialCondition this->NWUEnergy = Energy( NWUDensity, NWUPressure, gamma, NWUVelocity); this->NWUMomentum = NWUVelocity * NWUDensity; this->NWUTurbulentEnergy = NWUDensity * TurbulentEnergy( NWUVelocity, this->intensity); - this->NWUDisipation = this->turbulenceConstant * std::pow( NWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->NWUDisipation = std::sqrt(NWUTurbulentEnergy) / this->lengthScale; this->SWUDensity = preNWUDensity; this->SWUVelocity = PointLoad(preSWUVelocityX, preSWUVelocityY, preSWUVelocityZ); @@ -1652,7 +1652,7 @@ class RiemannProblemInitialCondition this->SWUEnergy = Energy( SWUDensity, SWUPressure, gamma, SWUVelocity); this->SWUMomentum = SWUVelocity * SWUDensity; this->SWUTurbulentEnergy = SWUDensity * TurbulentEnergy( SWUVelocity, this->intensity); - this->SWUDisipation = this->turbulenceConstant * std::pow( SWUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->SWUDisipation = std::sqrt(SWUTurbulentEnergy) / this->lengthScale; this->NWDDensity = preNWDDensity; this->NWDVelocity = PointLoad(preNWDVelocityX, preNWDVelocityY, preNWDVelocityZ); @@ -1660,7 +1660,7 @@ class RiemannProblemInitialCondition this->NWDEnergy = Energy( NWDDensity, NWDPressure, gamma, NWDVelocity); this->NWDMomentum = NWDVelocity * NWDDensity; this->NWDTurbulentEnergy = NWDDensity * TurbulentEnergy( NWDVelocity, this->intensity); - this->NWDDisipation = this->turbulenceConstant * std::pow( NWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->NWDDisipation = std::sqrt(NWDTurbulentEnergy) / this->lengthScale; this->SWDDensity = preSWDDensity; this->SWDVelocity = PointLoad(preSWDVelocityX, preSWDVelocityY, preSWDVelocityZ); @@ -1668,7 +1668,7 @@ class RiemannProblemInitialCondition this->SWDEnergy = Energy( SWDDensity, SWDPressure, gamma, SWDVelocity); this->SWDMomentum = SWDVelocity * SWDDensity; this->SWDTurbulentEnergy = SWDDensity * TurbulentEnergy( SWDVelocity, this->intensity); - this->SWDDisipation = this->turbulenceConstant * std::pow( SWDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->SWDDisipation = std::sqrt(SWDTurbulentEnergy) / this->lengthScale; this->NEUDensity = preNEUDensity; this->NEUVelocity = PointLoad(preNEUVelocityX, preNEUVelocityY, preNEUVelocityZ); @@ -1676,7 +1676,7 @@ class RiemannProblemInitialCondition this->NEUEnergy = Energy( NEUDensity, NEUPressure, gamma, NEUVelocity); this->NEUMomentum = NEUVelocity * NEUDensity; this->NEUTurbulentEnergy = NEUDensity * TurbulentEnergy( NEUVelocity, this->intensity); - this->NEUDisipation = this->turbulenceConstant * std::pow( NEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->NEUDisipation = std::sqrt(NEUTurbulentEnergy) / this->lengthScale; this->SEUDensity = preSEUDensity; this->SEUVelocity = PointLoad(preSEUVelocityX, preSEUVelocityY, preSEUVelocityZ); @@ -1684,7 +1684,7 @@ class RiemannProblemInitialCondition this->SEUEnergy = Energy( SEUDensity, SEUPressure, gamma, SEUVelocity); this->SEUMomentum = SEUVelocity * SEUDensity; this->SEUTurbulentEnergy = TurbulentEnergy( SEUVelocity, this->intensity); - this->SEUDisipation = this->turbulenceConstant * std::pow( SEUTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->SEUDisipation = std::sqrt(SEUTurbulentEnergy) / this->lengthScale; this->NEDDensity = preNEDDensity; this->NEDVelocity = PointLoad(preNEDVelocityX, preNEDVelocityY, preNEDVelocityZ); @@ -1692,7 +1692,7 @@ class RiemannProblemInitialCondition this->NEDEnergy = Energy( NEDDensity, NEDPressure, gamma, NEDVelocity); this->NEDMomentum = NEDVelocity * NEDDensity; this->NEDTurbulentEnergy = NEDDensity * TurbulentEnergy( NEDVelocity, this->intensity); - this->NEDDisipation = this->turbulenceConstant * std::pow( NEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->NEDDisipation = std::sqrt(NEDTurbulentEnergy) / this->lengthScale; this->SEDDensity = preSEDDensity; this->SEDVelocity = PointLoad(preSEDVelocityX, preSEDVelocityY, preSEDVelocityZ); @@ -1700,7 +1700,7 @@ class RiemannProblemInitialCondition this->SEDEnergy = Energy( SEDDensity, SEDPressure, gamma, SEDVelocity); this->SEDMomentum = SEDVelocity * SEDDensity; this->SEDTurbulentEnergy = SEDDensity * TurbulentEnergy( SEDVelocity, this->intensity); - this->SEDDisipation = this->turbulenceConstant * std::pow( SEDTurbulentEnergy, (3.0 / 2.0 ) ) / this->lengthScale; + this->SEDDisipation = std::sqrt(SEDTurbulentEnergy) / this->lengthScale; } diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h index 4bdb5c017..ceaf0b15e 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h @@ -315,7 +315,7 @@ getExplicitUpdate( const RealType& time, physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); physicalVariables.getTurbulentEnergy( this->conservativeVariables, this->turbulentEnergy ); physicalVariables.getDisipation( this->conservativeVariables, this->disipation ); -// physicalVariables.getTurbulentViscosity( this->conservativeVariables, this->turbulentEnergy, this->disipation, this->turbulenceConstant, this->turbulentViscosity ); + physicalVariables.getTurbulentViscosity( this->turbulentEnergy, this->disipation, this->turbulentViscosity ); /**** * Set-up operators -- GitLab From b08e9642f177e9e5b30d41b5197e8be723ddb12e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Sat, 20 Apr 2019 20:11:28 +0200 Subject: [PATCH 23/28] All previously described solver compilable not tested yet --- src/Examples/turbulent-flows/CMakeLists.txt | 2 +- .../zero-equation-model/Getter.h | 293 +++++++++++++++++ .../PhysicalVariablesGetter.h | 15 +- .../turbulentViscosityGetter.h | 299 ------------------ .../zeroEquationTurbulenceModelProblem_impl.h | 4 +- 5 files changed, 298 insertions(+), 315 deletions(-) create mode 100644 src/Examples/turbulent-flows/zero-equation-model/Getter.h delete mode 100644 src/Examples/turbulent-flows/zero-equation-model/turbulentViscosityGetter.h diff --git a/src/Examples/turbulent-flows/CMakeLists.txt b/src/Examples/turbulent-flows/CMakeLists.txt index bb1362258..34889faf6 100644 --- a/src/Examples/turbulent-flows/CMakeLists.txt +++ b/src/Examples/turbulent-flows/CMakeLists.txt @@ -1,3 +1,3 @@ -#add_subdirectory( zero-equation-model ) +add_subdirectory( zero-equation-model ) add_subdirectory( one-equation-model ) add_subdirectory( two-equation-model ) diff --git a/src/Examples/turbulent-flows/zero-equation-model/Getter.h b/src/Examples/turbulent-flows/zero-equation-model/Getter.h new file mode 100644 index 000000000..396767027 --- /dev/null +++ b/src/Examples/turbulent-flows/zero-equation-model/Getter.h @@ -0,0 +1,293 @@ +/*************************************************************************** + CompressibleConservativeVariables.h - description + ------------------- + begin : Feb 12, 2017 + copyright : (C) 2017 by Tomas Oberhuber + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/* See Copyright Notice in tnl/Copyright */ + +#pragma once + +#include +#include +#include +#include +#include "CompressibleConservativeVariables.h" + +namespace TNL { + template< typename Mesh, + typename Real = typename Mesh::RealType, + typename Index = typename Mesh::IndexType > +class TurbulentViscosityGetter +{ +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class TurbulentViscosityGetter< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + class Getter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + Getter( MeshFunctionPointer density, + VelocityFieldPointer velocity, + const RealType& mixingLength ) + : density( density ), velocity( velocity ), mixingLength( mixingLength ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + return 0; + } + + protected: + const MeshFunctionPointer density; + + const VelocityFieldPointer velocity; + + const RealType mixingLength; + }; + + void getTurbulentViscocsity( const ConservativeVariablesPointer& conservativeVariables, + VelocityFieldPointer& velocity, + const RealType& mixingLength, + MeshFunctionPointer& turbulentViscosity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, Getter > evaluator; + Pointers::SharedPointer< Getter, DeviceType > turbulentViscosityGetter( conservativeVariables->getDensity(), + velocity, + mixingLength ); + evaluator.evaluate( turbulentViscosity, turbulentViscosityGetter ); + } +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class TurbulentViscosityGetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + class Getter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + Getter( MeshFunctionPointer density, + VelocityFieldPointer velocity, + const RealType& mixingLength ) + : density( density ), velocity( velocity ), mixingLength( mixingLength ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + const typename EntityType::template NeighborEntities< 2 >& neighborEntities = meshEntity.getNeighborEntities(); + const RealType rho = this->density.template getData< DeviceType >()( meshEntity ); + const RealType& hxInverse = meshEntity.getMesh().template getSpaceStepsProducts< -1, 0 >(); + const RealType& hyInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + + const IndexType& center = meshEntity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + + return rho * this->mixingLength * this->mixingLength * + (-1.0) * + ( ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 + - ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 + ) + * + ( ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 + - ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 + ); + } + + protected: + const MeshFunctionPointer density; + + const VelocityFieldPointer velocity; + + const RealType mixingLength; + }; + + void getTurbulentViscocsity( const ConservativeVariablesPointer& conservativeVariables, + VelocityFieldPointer& velocity, + const RealType& mixingLength, + MeshFunctionPointer& turbulentViscosity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, Getter > evaluator; + Pointers::SharedPointer< Getter, DeviceType > turbulentViscosityGetter( conservativeVariables->getDensity(), + velocity, + mixingLength ); + evaluator.evaluate( turbulentViscosity, turbulentViscosityGetter ); + } +}; + +template< typename MeshReal, + typename Device, + typename MeshIndex, + typename Real, + typename Index > +class TurbulentViscosityGetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > +{ + public: + + typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; + typedef typename MeshType::RealType RealType; + typedef typename MeshType::DeviceType DeviceType; + typedef typename MeshType::IndexType IndexType; + static const int Dimensions = MeshType::getMeshDimension(); + + typedef Functions::MeshFunction< MeshType > MeshFunctionType; + typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; + typedef CompressibleConservativeVariables< MeshType > ConservativeVariablesType; + typedef Pointers::SharedPointer< ConservativeVariablesType > ConservativeVariablesPointer; + typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; + typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; + + class Getter : public Functions::Domain< Dimensions, Functions::MeshDomain > + { + public: + typedef typename MeshType::RealType RealType; + + Getter( MeshFunctionPointer density, + VelocityFieldPointer velocity, + const RealType& mixingLength ) + : density( density ), velocity( velocity ), mixingLength( mixingLength ) {} + + template< typename EntityType > + __cuda_callable__ + RealType operator()( const EntityType& meshEntity, + const RealType& time = 0.0 ) const + { + const typename EntityType::template NeighborEntities< 3 >& neighborEntities = meshEntity.getNeighborEntities(); + const RealType rho = this->density.template getData< DeviceType >()( meshEntity ); + + const RealType& hxInverse = meshEntity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); + const RealType& hyInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); + const RealType& hzInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + + const IndexType& center = meshEntity.getIndex(); + const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); + const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); + const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); + const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); + const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); + const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); + + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; + const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; + const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; + + const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; + const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; + const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; + const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; + const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + + return rho * this->mixingLength * this->mixingLength * + ( ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 + - ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 + ) + * + ( ( velocity_z_north - velocity_z_south ) * hyInverse * 0.5 + - ( velocity_y_up - velocity_y_down ) * hzInverse * 0.5 + ) + * + ( ( velocity_x_up - velocity_x_down ) * hzInverse * 0.5 + - ( velocity_z_east - velocity_z_west ) * hxInverse * 0.5 + ) + + + ( ( velocity_z_east - velocity_z_west ) * hxInverse * 0.5 + - ( velocity_x_up - velocity_x_down ) * hzInverse * 0.5 + ) + * + ( ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 + - ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 + ) + * + ( ( velocity_y_up - velocity_y_down ) * hzInverse * 0.5 + - ( velocity_z_north - velocity_z_south ) *hyInverse * 0.5 + ); + } + + protected: + const MeshFunctionPointer density; + + const VelocityFieldPointer velocity; + + const RealType mixingLength; + }; + + void getTurbulentViscocsity( const ConservativeVariablesPointer& conservativeVariables, + VelocityFieldPointer& velocity, + const RealType& mixingLength, + MeshFunctionPointer& turbulentViscosity ) + { + Functions::MeshFunctionEvaluator< MeshFunctionType, Getter > evaluator; + Pointers::SharedPointer< Getter, DeviceType > turbulentViscosityGetter( conservativeVariables->getDensity(), + velocity, + mixingLength ); + evaluator.evaluate( turbulentViscosity, turbulentViscosityGetter ); + } +}; + +} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/PhysicalVariablesGetter.h b/src/Examples/turbulent-flows/zero-equation-model/PhysicalVariablesGetter.h index 703bbabbf..957c9219c 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/PhysicalVariablesGetter.h +++ b/src/Examples/turbulent-flows/zero-equation-model/PhysicalVariablesGetter.h @@ -15,7 +15,6 @@ #include #include #include "CompressibleConservativeVariables.h" -#include "turbulentViscosityGetter.h" namespace TNL { @@ -116,19 +115,7 @@ class PhysicalVariablesGetter conservativeVariables->getMomentum(), gamma ); evaluator.evaluate( pressure, pressureGetter ); - } - - void getTurbulentViscocsity( const ConservativeVariablesPointer& conservativeVariables, - VelocityFieldPointer& velocity, - const RealType& mixingLength, - MeshFunctionPointer& turbulentViscosity ) - { - Functions::MeshFunctionEvaluator< MeshFunctionType, TurbulentViscosityGetter < MeshType > > evaluator; - Pointers::SharedPointer< TurbulentViscosityGetter < MeshType >, DeviceType > turbulentViscosityGetter( conservativeVariables->getDensity(), - velocity, - mixingLength ); - evaluator.evaluate( turbulentViscosity, turbulentViscosityGetter ); - } + } }; } //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/turbulentViscosityGetter.h b/src/Examples/turbulent-flows/zero-equation-model/turbulentViscosityGetter.h deleted file mode 100644 index 950d56c26..000000000 --- a/src/Examples/turbulent-flows/zero-equation-model/turbulentViscosityGetter.h +++ /dev/null @@ -1,299 +0,0 @@ -/*************************************************************************** - TurbulentViscosityGetter.h - description - ------------------- - begin : Feb 17, 2017 - copyright : (C) 2017 by Tomas Oberhuber - email : tomas.oberhuber@fjfi.cvut.cz - ***************************************************************************/ - -/* See Copyright Notice in tnl/Copyright */ - - -#pragma once - -#include -#include -#include -#include -#include -#include - -namespace TNL { - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class TurbulentViscosityGetterBase : public Functions::Domain< Mesh::getMeshDimension(), Functions::MeshDomain > -{ - public: - - typedef Real RealType; - typedef Index IndexType; - typedef Mesh MeshType; - typedef typename MeshType::DeviceType DeviceType; - typedef typename MeshType::CoordinatesType CoordinatesType; - typedef Functions::MeshFunction< MeshType > MeshFunctionType; - static const int Dimensions = MeshType::getMeshDimension(); - typedef Functions::VectorField< Dimensions, MeshFunctionType > VelocityFieldType; - typedef Pointers::SharedPointer< VelocityFieldType > VelocityFieldPointer; - typedef Pointers::SharedPointer< MeshFunctionType > MeshFunctionPointer; - - TurbulentViscosityGetterBase( MeshFunctionPointer density, - VelocityFieldPointer velocity, - const RealType& mixingLength ) - : density( density ), velocity( velocity ), mixingLength( mixingLength ) {} - - static String getType() - { - return String( "TurbulentViscosityGetter< " ) + - MeshType::getType() + ", " + - TNL::getType< Real >() + ", " + - TNL::getType< Index >() + " >"; - } - - protected: - const MeshFunctionPointer density; - - const VelocityFieldPointer velocity; - - const RealType mixingLength; - - - -}; - -template< typename Mesh, - typename Real = typename Mesh::RealType, - typename Index = typename Mesh::IndexType > -class TurbulentViscosityGetter -{ -}; - - - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class TurbulentViscosityGetter< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > - : public TurbulentViscosityGetterBase< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType; - typedef TurbulentViscosityGetterBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename MeshEntity > - __cuda_callable__ - Real operator()( const MeshEntity& entity, - const RealType& time = 0.0 ) const - { - return 0; - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class TurbulentViscosityGetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > - : public TurbulentViscosityGetterBase< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType; - typedef TurbulentViscosityGetterBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - const typename EntityType::template NeighborEntities< 2 >& neighborEntities = meshEntity.getNeighborEntities(); - const RealType rho = this->density.template getData< DeviceType >()( meshEntity ); - const RealType& hxInverse = meshEntity.getMesh().template getSpaceStepsProducts< -1, 0 >(); - const RealType& hyInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, -1 >(); - - const IndexType& center = meshEntity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - - return rho * this->mixingLength * this->mixingLength * - (-1.0) * - ( ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 - - ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 - ) - * - ( ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 - - ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - -template< typename MeshReal, - typename Device, - typename MeshIndex, - typename Real, - typename Index > -class TurbulentViscosityGetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > - : public TurbulentViscosityGetterBase< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Real, Index > -{ - public: - typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType; - typedef TurbulentViscosityGetterBase< MeshType, Real, Index > BaseType; - - using typename BaseType::RealType; - using typename BaseType::IndexType; - using typename BaseType::DeviceType; - using typename BaseType::CoordinatesType; - using typename BaseType::MeshFunctionType; - using typename BaseType::VelocityFieldType; - using typename BaseType::VelocityFieldPointer; - using BaseType::Dimensions; - - template< typename EntityType > - __cuda_callable__ - RealType operator()( const EntityType& meshEntity, - const RealType& time = 0.0 ) const - { - const typename EntityType::template NeighborEntities< 3 >& neighborEntities = meshEntity.getNeighborEntities(); - const RealType rho = this->density.template getData< DeviceType >()( meshEntity ); - - const RealType& hxInverse = meshEntity.getMesh().template getSpaceStepsProducts< -1, 0, 0 >(); - const RealType& hyInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); - const RealType& hzInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); - - const IndexType& center = meshEntity.getIndex(); - const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); - const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); - const IndexType& north = neighborEntities.template getEntityIndex< 0, 1, 0 >(); - const IndexType& south = neighborEntities.template getEntityIndex< 0, -1, 0 >(); - const IndexType& up = neighborEntities.template getEntityIndex< 0, 0, 1 >(); - const IndexType& down = neighborEntities.template getEntityIndex< 0, 0, -1 >(); - - const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_x_up = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_x_down = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_y_east = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_y_west = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_y_center = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ center ]; - const RealType& velocity_y_up = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ up ]; - const RealType& velocity_y_down = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ down ]; - - const RealType& velocity_z_north = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ north ]; - const RealType& velocity_z_south = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ south ]; - const RealType& velocity_z_east = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ east ]; - const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; - const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - - return rho * this->mixingLength * this->mixingLength * - ( ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 - - ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 - ) - * - ( ( velocity_z_north - velocity_z_south ) * hyInverse * 0.5 - - ( velocity_y_up - velocity_y_down ) * hzInverse * 0.5 - ) - * - ( ( velocity_x_up - velocity_x_down ) * hzInverse * 0.5 - - ( velocity_z_east - velocity_z_west ) * hxInverse * 0.5 - ) - + - ( ( velocity_z_east - velocity_z_west ) * hxInverse * 0.5 - - ( velocity_x_up - velocity_x_down ) * hzInverse * 0.5 - ) - * - ( ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 - - ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 - ) - * - ( ( velocity_y_up - velocity_y_down ) * hzInverse * 0.5 - - ( velocity_z_north - velocity_z_south ) *hyInverse * 0.5 - ); - } - - /*template< typename MeshEntity > - __cuda_callable__ - Index getLinearSystemRowLength( const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity ) const; - - template< typename MeshEntity, typename Vector, typename MatrixRow > - __cuda_callable__ - void updateLinearSystem( const RealType& time, - const RealType& tau, - const MeshType& mesh, - const IndexType& index, - const MeshEntity& entity, - const MeshFunctionType& u, - Vector& b, - MatrixRow& matrixRow ) const;*/ -}; - - -} //namespace TNL diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h index 16f821393..10d52e90c 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h @@ -21,6 +21,7 @@ #include "CompressibleConservativeVariables.h" #include "PhysicalVariablesGetter.h" #include "zeroEquationTurbulenceModelProblem.h" +#include "Getter.h" namespace TNL { @@ -287,7 +288,8 @@ getExplicitUpdate( const RealType& time, PhysicalVariablesGetter< typename MeshPointer::ObjectType > physicalVariables; physicalVariables.getVelocity( this->conservativeVariables, this->velocity ); physicalVariables.getPressure( this->conservativeVariables, this->gamma, this->pressure ); - physicalVariables.getTurbulentViscocsity( this->conservativeVariables, this->velocity, this->mixingLength, this->turbulentViscosity ); + TurbulentViscosityGetter< typename MeshPointer::ObjectType > turbViscosity; + turbViscosity.getTurbulentViscocsity( this->conservativeVariables, this->velocity, this->mixingLength, this->turbulentViscosity ); /**** * Set-up operators -- GitLab From 95d8994afa9f078425b648c52695ca631bd85ae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Sun, 21 Apr 2019 17:57:30 +0200 Subject: [PATCH 24/28] all mentioned solvers tested and working --- .../AUSM+/AUSMPlus.h | 4 ++++ .../AUSM+/AUSMPlusEnergy.h | 1 + .../AUSM+/AUSMPlusMomentumBase.h | 1 + .../AUSM+/AUSMPlusTurbulentEnergy.h | 2 ++ .../Lax-Friedrichs/LaxFridrichs.h | 6 +++++- .../Lax-Friedrichs/LaxFridrichsEnergy.h | 7 ++++++- .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 7 ++++++- .../Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h | 5 +++++ .../Steger-Warming/StegerWarmingEnergy.h | 1 + .../Steger-Warming/StegerWarmingMomentumBase.h | 1 + .../StegerWarmingTurbulentEnergy.h | 1 + .../VanLeer/VanLeer.h | 4 ++++ .../VanLeer/VanLeerEnergy.h | 1 + .../VanLeer/VanLeerMomentumBase.h | 1 + .../VanLeer/VanLeerTurbulentEnergy.h | 2 ++ ...mogorovTurbulentEnergyOperatorRightHandSide.h | 6 +++--- .../oneEquationTurbulenceModelProblem_impl.h | 10 +++++++++- .../oneEquationTurbulenceModelVanLeer.h | 4 ++++ .../AUSM+/AUSMPlusEnergy.h | 1 + .../AUSM+/AUSMPlusMomentumBase.h | 1 + .../Lax-Friedrichs/LaxFridrichs.h | 6 +++++- .../Lax-Friedrichs/LaxFridrichsEnergy.h | 7 ++++++- .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 5 +++++ .../Steger-Warming/StegerWarmingEnergy.h | 1 + .../Steger-Warming/StegerWarmingMomentumBase.h | 1 + .../VanLeer/VanLeerEnergy.h | 1 + .../VanLeer/VanLeerMomentumBase.h | 1 + .../twoEquationTurbulenceModelProblem_impl.h | 5 ++++- .../AUSM+/AUSMPlusEnergy.h | 1 + .../AUSM+/AUSMPlusMomentumBase.h | 1 + .../Lax-Friedrichs/LaxFridrichs.h | 6 +++++- .../Lax-Friedrichs/LaxFridrichsEnergy.h | 7 ++++++- .../Lax-Friedrichs/LaxFridrichsMomentumBase.h | 5 +++++ .../Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h | 5 +++++ .../Steger-Warming/StegerWarmingEnergy.h | 1 + .../Steger-Warming/StegerWarmingMomentumBase.h | 1 + .../VanLeer/VanLeerEnergy.h | 6 +----- .../VanLeer/VanLeerMomentumBase.h | 1 + .../twoEquationTurbulenceModelAUSMPlus.h | 5 +++-- .../twoEquationTurbulenceModelLaxFriedrichs.h | 5 +++-- .../twoEquationTurbulenceModelProblem_impl.h | 7 +++++-- .../twoEquationTurbulenceModelVanLeer.h | 5 +++-- .../turbulent-flows/zero-equation-model/Getter.h | 16 +++++++++++++++- .../zeroEquationTurbulenceModelAUSMPlus.h | 1 + .../zeroEquationTurbulenceModelLaxFriedrichs.h | 2 +- .../zeroEquationTurbulenceModelProblem_impl.h | 6 ++++++ .../zeroEquationTurbulenceModelStegerWarming.h | 1 + .../zeroEquationTurbulenceModelVanLeer.h | 1 + 48 files changed, 149 insertions(+), 27 deletions(-) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlus.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlus.h index b9e1de467..025a634de 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlus.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlus.h @@ -165,6 +165,10 @@ class AUSMPlus void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) { + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); } diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h index fa7b33b42..52b3c1866 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h @@ -70,6 +70,7 @@ class AUSMPlusEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setArtificialViscosity( const RealType& artificialViscosity ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h index a65ba0174..6ce94d08d 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h @@ -53,6 +53,7 @@ class AUSMPlusMomentumBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setPressure( const MeshFunctionPointer& pressure ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h index 787bdab9f..d82503879 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h @@ -65,11 +65,13 @@ class AUSMPlusTurbulentEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setVelocity( const VelocityFieldPointer& velocity ) { this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); }; void setDynamicalViscosity( const RealType& dynamicalViscosity ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h index 53370ca34..2581452d2 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h @@ -132,7 +132,11 @@ class LaxFridrichs void setDensity( const MeshFunctionPointer& density ) { - + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); + this->turbulentEnergyOperatorPointer->setDensity( density ); } void setTurbulentViscosity( const MeshFunctionPointer& turbulentViscosity ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h index 16256aa80..89743fae6 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -80,7 +80,12 @@ class LaxFridrichsEnergyBase void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) { this->rightHandSide.setTurbulentEnergy(turbulentEnergy); - }; + }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->rightHandSide.setDensity(density); + } protected: diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h index cde9e58c8..918cba082 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -70,7 +70,12 @@ class LaxFridrichsMomentumBase void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) { this->rightHandSide.setTurbulentEnergy(turbulentEnergy); - } + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->rightHandSide.setDensity(density); + } protected: diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h index 02c03dffa..3c434196e 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h @@ -96,6 +96,11 @@ class LaxFridrichsTurbulentEnergyBase this->rightHandSide.setViscosityConstant( ViscosityConstant ); } + void setDensity( const MeshFunctionPointer& density ) + { + this->rightHandSide.setDensity(density); + } + protected: diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h index f51bf7e53..05d8c3b1f 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h @@ -67,6 +67,7 @@ class StegerWarmingEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setDynamicalViscosity( const RealType& dynamicalViscosity ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h index e6c6c1fbb..227c88486 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h @@ -53,6 +53,7 @@ class StegerWarmingMomentumBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setPressure( const MeshFunctionPointer& pressure ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h index 774b076df..ff59b864d 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h @@ -71,6 +71,7 @@ class StegerWarmingTurbulentEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setDynamicalViscosity( const RealType& dynamicalViscosity ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeer.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeer.h index 49f31db83..e4d6d113d 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeer.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeer.h @@ -165,6 +165,10 @@ class VanLeer void setTurbulentEnergy( const MeshFunctionPointer& turbulentEnergy ) { + this->momentumXOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumYOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->momentumZOperatorPointer->setTurbulentEnergy( turbulentEnergy ); + this->energyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); this->turbulentEnergyOperatorPointer->setTurbulentEnergy( turbulentEnergy ); } diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerEnergy.h index 3e372e54a..4e19cdda4 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerEnergy.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerEnergy.h @@ -70,6 +70,7 @@ class VanLeerEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setArtificialViscosity( const RealType& artificialViscosity ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h index d8e80c103..a1901fb7c 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h @@ -53,6 +53,7 @@ class VanLeerMomentumBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setPressure( const MeshFunctionPointer& pressure ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h index fa4cb0db4..bdfc5be32 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h @@ -65,11 +65,13 @@ class VanLeerTurbulentEnergyBase void setVelocity( const VelocityFieldPointer& velocity ) { this->velocity = velocity; + this->rightHandSide.setVelocity(velocity); }; void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setDynamicalViscosity( const RealType& dynamicalViscosity ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h index d48f5c3c4..8dc13ed34 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h @@ -188,7 +188,7 @@ class PrandtlKolmogorovTurbulentEnergyRightHandSide< Meshes::Grid< 1, MeshReal, * this->dynamicalViscosity * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 - - density_center / this->characteristicLength * std::pow( turbulentEnergy_center, 2.0 / 3.0 ) + - density_center / this->characteristicLength * std::pow( std::abs( turbulentEnergy_center ), 2.0 / 3.0 ) + this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) @@ -318,7 +318,7 @@ class PrandtlKolmogorovTurbulentEnergyRightHandSide< Meshes::Grid< 2, MeshReal, ) * this->dynamicalViscosity * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 - - density_center / this->characteristicLength * std::pow( turbulentEnergy_center, 2.0 / 3.0 ) + - density_center / this->characteristicLength * std::pow( std::abs( turbulentEnergy_center ), 2.0 / 3.0 ) + this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) @@ -528,7 +528,7 @@ class PrandtlKolmogorovTurbulentEnergyRightHandSide< Meshes::Grid< 3, MeshReal, ) * this->dynamicalViscosity * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 - - density_center / this->characteristicLength * std::pow( turbulentEnergy_center, 2.0 / 3.0 ) + - density_center / this->characteristicLength * std::pow( std::abs( turbulentEnergy_center ), 2.0 / 3.0 ) + this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem_impl.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem_impl.h index 449b58ec2..0b4699c0f 100644 --- a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem_impl.h +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelProblem_impl.h @@ -90,6 +90,8 @@ setup( const Config::ParameterContainer& parameters, this->intensity = parameters.getParameter< double >( "turbulence-intensity" ); velocity->setMesh( this->getMesh() ); pressure->setMesh( this->getMesh() ); + turbulentViscosity->setMesh( this->getMesh() ); + turbulentEnergy->setMesh( this->getMesh() ); /**** * Set-up operators @@ -272,6 +274,11 @@ makeSnapshot( const RealType& time, // if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) this->conservativeVariables->getEnergy()->save( fileName.getFileName() ); // return false; + + fileName.setFileNameBase( "turbulentEnergy-" ); +// if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) + this->conservativeVariables->getTurbulentEnergy()->save( fileName.getFileName() ); +// return false; return true; } @@ -428,13 +435,14 @@ applyBoundaryConditions( const RealType& time, */ this->explicitUpdaterEnergy.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, this->conservativeVariables->getEnergy() ); // uRhoVelocityX, - + /**** * Turbulent energy equation */ this->explicitUpdaterTurbulentEnergy.template applyBoundaryConditions< typename Mesh::Cell >( this->getMesh(), time, this->conservativeVariables->getTurbulentEnergy() ); // uRhoVelocityX, + } template< typename Mesh, diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h index eec8a4bf1..eace7dc45 100644 --- a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h @@ -52,6 +52,10 @@ template< typename ConfigTag >class oneEquationTurbulenceModelConfig config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "characteristic-length", "Value of characteristic mixing length", 1.0 ); + config.addEntry< double >( "viscosity-constant", "Value of viscosity constant", 1.0 ); + config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); typedef Meshes::Grid< 3 > Mesh; VanLeer< Mesh >::configSetup( config, "inviscid-operators-" ); RiemannProblemInitialCondition< Mesh >::configSetup( config ); diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h index fa7b33b42..52b3c1866 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h @@ -70,6 +70,7 @@ class AUSMPlusEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setArtificialViscosity( const RealType& artificialViscosity ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h index a65ba0174..6ce94d08d 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h @@ -53,6 +53,7 @@ class AUSMPlusMomentumBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setPressure( const MeshFunctionPointer& pressure ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h index be4d84528..52761a1c0 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h @@ -136,9 +136,13 @@ class LaxFridrichs this->turbulentEnergyOperatorPointer->setVelocity( velocity ); this->disipationOperatorPointer->setVelocity( velocity ); } - + void setDensity( const MeshFunctionPointer& density ) { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); this->disipationOperatorPointer->setDensity( density ); } diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h index 16256aa80..ab7c416d8 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -65,7 +65,12 @@ class LaxFridrichsEnergyBase void setArtificialViscosity( const RealType& artificialViscosity ) { this->artificialViscosity = artificialViscosity; - } + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->rightHandSide.setDensity( density ); + }; void setDynamicalViscosity( const RealType& dynamicalViscosity ) { diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h index cde9e58c8..c44f57770 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -57,6 +57,11 @@ class LaxFridrichsMomentumBase this->artificialViscosity = artificialViscosity; } + void setDensity( const MeshFunctionPointer& density ) + { + this->rightHandSide.setDensity( density ); + }; + void setDynamicalViscosity( const RealType& dynamicalViscosity ) { this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h index f51bf7e53..05d8c3b1f 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h @@ -67,6 +67,7 @@ class StegerWarmingEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setDynamicalViscosity( const RealType& dynamicalViscosity ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h index e6c6c1fbb..227c88486 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h @@ -53,6 +53,7 @@ class StegerWarmingMomentumBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setPressure( const MeshFunctionPointer& pressure ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h index 3e372e54a..4e19cdda4 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h @@ -70,6 +70,7 @@ class VanLeerEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setArtificialViscosity( const RealType& artificialViscosity ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h index d8e80c103..a1901fb7c 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h @@ -53,6 +53,7 @@ class VanLeerMomentumBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setPressure( const MeshFunctionPointer& pressure ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem_impl.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem_impl.h index bc7594fb5..c7c6b3b7c 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem_impl.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelProblem_impl.h @@ -90,9 +90,12 @@ setup( const Config::ParameterContainer& parameters, this->sigmaK = parameters.getParameter< double >( "sigma-k" ); this->sigmaEpsilon = parameters.getParameter< double >( "sigma-epsilon" ); this->intensity = parameters.getParameter< double >( "turbulence-intensity" ); - this->lengthScale = parameters.getParameter< double >( "length-scale" ); + this->lengthScale = parameters.getParameter< double >( "turbulence-length-scale" ); velocity->setMesh( this->getMesh() ); pressure->setMesh( this->getMesh() ); + turbulentViscosity->setMesh( this->getMesh() ); + turbulentEnergy->setMesh( this->getMesh() ); + disipation->setMesh( this->getMesh() ); /**** * Set-up operators diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h index fa7b33b42..31787bb8d 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h @@ -70,6 +70,7 @@ class AUSMPlusEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity( density ); }; void setArtificialViscosity( const RealType& artificialViscosity ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h index a65ba0174..74fe948cd 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h @@ -53,6 +53,7 @@ class AUSMPlusMomentumBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity( density ); }; void setPressure( const MeshFunctionPointer& pressure ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h index 582b3ff39..d8949290a 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h @@ -136,9 +136,13 @@ class LaxFridrichs this->turbulentEnergyOperatorPointer->setVelocity( velocity ); this->disipationOperatorPointer->setVelocity( velocity ); } - + void setDensity( const MeshFunctionPointer& density ) { + this->momentumXOperatorPointer->setDensity( density ); + this->momentumYOperatorPointer->setDensity( density ); + this->momentumZOperatorPointer->setDensity( density ); + this->energyOperatorPointer->setDensity( density ); this->disipationOperatorPointer->setDensity( density ); } diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h index 16256aa80..ab7c416d8 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsEnergy.h @@ -65,7 +65,12 @@ class LaxFridrichsEnergyBase void setArtificialViscosity( const RealType& artificialViscosity ) { this->artificialViscosity = artificialViscosity; - } + } + + void setDensity( const MeshFunctionPointer& density ) + { + this->rightHandSide.setDensity( density ); + }; void setDynamicalViscosity( const RealType& dynamicalViscosity ) { diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h index cde9e58c8..c44f57770 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsMomentumBase.h @@ -57,6 +57,11 @@ class LaxFridrichsMomentumBase this->artificialViscosity = artificialViscosity; } + void setDensity( const MeshFunctionPointer& density ) + { + this->rightHandSide.setDensity( density ); + }; + void setDynamicalViscosity( const RealType& dynamicalViscosity ) { this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h index 5d1232d41..d3b41a070 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h @@ -66,6 +66,11 @@ class LaxFridrichsTurbulentEnergyBase this->artificialViscosity = artificialViscosity; } + void setDensity( const MeshFunctionPointer& density ) + { + this->rightHandSide.setDensity( density ); + }; + void setDynamicalViscosity( const RealType& dynamicalViscosity ) { this->rightHandSide.setDynamicalViscosity(dynamicalViscosity); diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h index f51bf7e53..3dad25525 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingEnergy.h @@ -67,6 +67,7 @@ class StegerWarmingEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity( density ); }; void setDynamicalViscosity( const RealType& dynamicalViscosity ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h index e6c6c1fbb..b13dd0894 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingMomentumBase.h @@ -53,6 +53,7 @@ class StegerWarmingMomentumBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity( density ); }; void setPressure( const MeshFunctionPointer& pressure ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h index 3e372e54a..238b0d7ab 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerEnergy.h @@ -70,11 +70,7 @@ class VanLeerEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; - }; - - void setArtificialViscosity( const RealType& artificialViscosity ) - { - this->artificialViscosity = artificialViscosity; + this->rightHandSide.setDensity( density ); }; void setDynamicalViscosity( const RealType& dynamicalViscosity ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h index d8e80c103..b34768577 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerMomentumBase.h @@ -53,6 +53,7 @@ class VanLeerMomentumBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity( density ); }; void setPressure( const MeshFunctionPointer& pressure ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h index 2641ae2e7..e79e14d2c 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h @@ -53,10 +53,11 @@ template< typename ConfigTag >class twoEquationTurbulenceModelConfig config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); config.addEntry< double >( "turbulence-constant", "Value of turbulence constant", 1.0 ); - config.addEntry< double >( "viscosity-constant-1", "Value of viscosity constant C_epsilon_1", 1.0 ); - config.addEntry< double >( "viscosity-constant-2", "Value of viscosity constant C_epsilon_2", 1.0 ); + config.addEntry< double >( "beta", "Value of viscosity constant beta", 1.0 ); + config.addEntry< double >( "beta-star", "Value of viscosity constant beta_star", 1.0 ); config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); config.addEntry< double >( "sigma-epsilon", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "alpha", "Value of alpha constant", 1.0 ); config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); config.addEntry< double >( "turbulence-length-scale", "meassure of turbulence intensity", 1.0 ); typedef Meshes::Grid< 3 > Mesh; diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h index 8b12e4c32..45d4d996d 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h @@ -53,10 +53,11 @@ template< typename ConfigTag >class twoEquationTurbulenceModelConfig config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); config.addEntry< double >( "turbulence-constant", "Value of turbulence constant", 1.0 ); - config.addEntry< double >( "viscosity-constant-1", "Value of viscosity constant C_epsilon_1", 1.0 ); - config.addEntry< double >( "viscosity-constant-2", "Value of viscosity constant C_epsilon_2", 1.0 ); + config.addEntry< double >( "beta", "Value of viscosity constant beta", 1.0 ); + config.addEntry< double >( "beta-star", "Value of viscosity constant beta_star", 1.0 ); config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); config.addEntry< double >( "sigma-epsilon", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "alpha", "Value of alpha constant", 1.0 ); config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); config.addEntry< double >( "turbulence-length-scale", "meassure of turbulence intensity", 1.0 ); typedef Meshes::Grid< 3 > Mesh; diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h index ceaf0b15e..0c3d4ec29 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelProblem_impl.h @@ -87,13 +87,16 @@ setup( const Config::ParameterContainer& parameters, this->turbulenceConstant = parameters.getParameter< double >( "turbulence-constant" ); this->beta = parameters.getParameter< double >( "beta" ); this->betaStar = parameters.getParameter< double >( "beta-star" ); - this->alpha = parameters.getParameter< double >( "aplha" ); + this->alpha = parameters.getParameter< double >( "alpha" ); this->sigmaK = parameters.getParameter< double >( "sigma-k" ); this->sigmaEpsilon = parameters.getParameter< double >( "sigma-epsilon" ); this->intensity = parameters.getParameter< double >( "turbulence-intensity" ); - this->lengthScale = parameters.getParameter< double >( "length-scale" ); + this->lengthScale = parameters.getParameter< double >( "turbulence-length-scale" ); velocity->setMesh( this->getMesh() ); pressure->setMesh( this->getMesh() ); + turbulentViscosity->setMesh( this->getMesh() ); + turbulentEnergy->setMesh( this->getMesh() ); + disipation->setMesh( this->getMesh() ); /**** * Set-up operators diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h index 002ea592f..cba2a3a06 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h @@ -53,10 +53,11 @@ template< typename ConfigTag >class twoEquationTurbulenceModelConfig config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); config.addEntry< double >( "turbulence-constant", "Value of turbulence constant", 1.0 ); - config.addEntry< double >( "viscosity-constant-1", "Value of viscosity constant C_epsilon_1", 1.0 ); - config.addEntry< double >( "viscosity-constant-2", "Value of viscosity constant C_epsilon_2", 1.0 ); + config.addEntry< double >( "beta", "Value of viscosity constant beta", 1.0 ); + config.addEntry< double >( "beta-star", "Value of viscosity constant beta_star", 1.0 ); config.addEntry< double >( "sigma-k", "Value of sigma constant", 1.0 ); config.addEntry< double >( "sigma-epsilon", "Value of sigma constant", 1.0 ); + config.addEntry< double >( "alpha", "Value of alpha constant", 1.0 ); config.addEntry< double >( "turbulence-intensity", "meassure of turbulence intensity", 1.0 ); config.addEntry< double >( "turbulence-length-scale", "meassure of turbulence intensity", 1.0 ); typedef Meshes::Grid< 3 > Mesh; diff --git a/src/Examples/turbulent-flows/zero-equation-model/Getter.h b/src/Examples/turbulent-flows/zero-equation-model/Getter.h index 396767027..612b53618 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/Getter.h +++ b/src/Examples/turbulent-flows/zero-equation-model/Getter.h @@ -126,13 +126,16 @@ class TurbulentViscosityGetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, const RealType rho = this->density.template getData< DeviceType >()( meshEntity ); const RealType& hxInverse = meshEntity.getMesh().template getSpaceStepsProducts< -1, 0 >(); const RealType& hyInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, -1 >(); + if( ! ( ( ( meshEntity.getCoordinates().x() == 0 ) || ( meshEntity.getCoordinates().x() == meshEntity.getMesh().getDimensions().x() - 1 ) ) + ||( ( meshEntity.getCoordinates().y() == 0 ) || ( meshEntity.getCoordinates().y() == meshEntity.getMesh().getDimensions().y() - 1 ) ) ) ) + { const IndexType& center = meshEntity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1, 0 >(); const IndexType& north = neighborEntities.template getEntityIndex< 0, 1 >(); const IndexType& south = neighborEntities.template getEntityIndex< 0, -1 >(); - + const RealType& velocity_x_north = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ north ]; const RealType& velocity_x_south = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ south ]; const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; @@ -150,6 +153,8 @@ class TurbulentViscosityGetter< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, ( ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 - ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 ); + } + else return 0; } protected: @@ -217,6 +222,10 @@ class TurbulentViscosityGetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, const RealType& hyInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, -1, 0 >(); const RealType& hzInverse = meshEntity.getMesh().template getSpaceStepsProducts< 0, 0, -1 >(); + if( ! ( ( ( meshEntity.getCoordinates().x() == 0 ) || ( meshEntity.getCoordinates().x() == meshEntity.getMesh().getDimensions().x() - 1 ) ) + ||( ( meshEntity.getCoordinates().y() == 0 ) || ( meshEntity.getCoordinates().y() == meshEntity.getMesh().getDimensions().y() - 1 ) ) + ||( ( meshEntity.getCoordinates().z() == 0 ) || ( meshEntity.getCoordinates().z() == meshEntity.getMesh().getDimensions().z() - 1 ) ) ) ) + { const IndexType& center = meshEntity.getIndex(); const IndexType& east = neighborEntities.template getEntityIndex< 1, 0, 0 >(); const IndexType& west = neighborEntities.template getEntityIndex< -1, 0, 0 >(); @@ -243,6 +252,9 @@ class TurbulentViscosityGetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; + if( ! ( ( ( meshEntity.getCoordinates().x() == 0 ) || ( meshEntity.getCoordinates().x() == meshEntity.getMesh().getDimensions().x() - 1 ) ) + ||( ( meshEntity.getCoordinates().y() == 0 ) || ( meshEntity.getCoordinates().x() == meshEntity.getMesh().getDimensions().y() - 1 ) ) + ||( ( meshEntity.getCoordinates().z() == 0 ) || ( meshEntity.getCoordinates().x() == meshEntity.getMesh().getDimensions().z() - 1 ) ) ) ) return rho * this->mixingLength * this->mixingLength * ( ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 - ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 @@ -268,6 +280,8 @@ class TurbulentViscosityGetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, - ( velocity_z_north - velocity_z_south ) *hyInverse * 0.5 ); } + else return 0; + } protected: const MeshFunctionPointer density; diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.h index ea02ee501..6fd07ef64 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.h +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelAUSMPlus.h @@ -52,6 +52,7 @@ template< typename ConfigTag >class zeroEquationTurbulenceModelConfig config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "mixing-length", "Value of characteristic mixing length", 1.0 ); typedef Meshes::Grid< 3 > Mesh; AUSMPlus< Mesh >::configSetup( config, "inviscid-operators-" ); RiemannProblemInitialCondition< Mesh >::configSetup( config ); diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.h index 2949183a4..8f86274c7 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.h +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelLaxFriedrichs.h @@ -52,6 +52,7 @@ template< typename ConfigTag >class zeroEquationTurbulenceModelConfig config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "mixing-length", "Value of characteristic mixing length", 1.0 ); typedef Meshes::Grid< 3 > Mesh; LaxFridrichs< Mesh >::configSetup( config, "inviscid-operators-" ); RiemannProblemInitialCondition< Mesh >::configSetup( config ); @@ -85,7 +86,6 @@ class zeroEquationTurbulenceModelSetter typedef flowsRhs< MeshType, Real > RightHandSide; typedef Containers::StaticVector < MeshType::getMeshDimension(), Real > Point; - String operatorRightHandSideType = parameters.getParameter< String >( "operator-right-hand-side"); typedef PrandtlOperatorRightHandSide< MeshType, Real, Index > OperatorRightHandSide; typedef LaxFridrichs< MeshType, OperatorRightHandSide, Real, Index > ApproximateOperator; typedef Functions::Analytic::Constant< Dimension, Real > Constant; diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h index 10d52e90c..73b08d1ee 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelProblem_impl.h @@ -88,6 +88,7 @@ setup( const Config::ParameterContainer& parameters, this->mixingLength = parameters.getParameter< RealType >( "mixing-length" ); velocity->setMesh( this->getMesh() ); pressure->setMesh( this->getMesh() ); + turbulentViscosity->setMesh( this->getMesh() ); /**** * Set-up operators @@ -259,6 +260,11 @@ makeSnapshot( const RealType& time, // if( ! this->conservativeVariables->getEnergy()->save( fileName.getFileName() ) ) this->conservativeVariables->getEnergy()->save( fileName.getFileName() ); // return false; + + fileName.setFileNameBase( "turbulentViscosity-" ); +// if( ! this->pressure->save( fileName.getFileName() ) ) + this->turbulentViscosity->save( fileName.getFileName() ); +// return false; return true; } diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.h index 3dfbd1640..c6ec60a70 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.h +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelStegerWarming.h @@ -52,6 +52,7 @@ template< typename ConfigTag >class zeroEquationTurbulenceModelConfig config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "mixing-length", "Value of characteristic mixing length", 1.0 ); typedef Meshes::Grid< 3 > Mesh; StegerWarming< Mesh >::configSetup( config, "inviscid-operators-" ); RiemannProblemInitialCondition< Mesh >::configSetup( config ); diff --git a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.h b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.h index 9d8705849..50014a927 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.h +++ b/src/Examples/turbulent-flows/zero-equation-model/zeroEquationTurbulenceModelVanLeer.h @@ -55,6 +55,7 @@ template< typename ConfigTag >class zeroEquationTurbulenceModelConfig config.addEntry< double >( "start-speed-h-throttle", "This sets throttle speed at begining for horizontal throttle", 0.0 ); config.addEntry< double >( "final-speed-h-throttle", "This sets speed at destined time for horizontal throttle", 0.0 ); config.addEntry< double >( "cavity-speed", "This sets speed parameter of cavity", 0.0 ); + config.addEntry< double >( "mixing-length", "Value of characteristic mixing length", 1.0 ); typedef Meshes::Grid< 3 > Mesh; VanLeer< Mesh >::configSetup( config, "inviscid-operators-" ); RiemannProblemInitialCondition< Mesh >::configSetup( config ); -- GitLab From 45714ea3c2eb1d068833dffbe9901ed69dc54475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Mon, 22 Apr 2019 08:46:51 +0200 Subject: [PATCH 25/28] fix for case sensitive filesystems --- .../one-equation-model/oneEquationTurbulenceModelAUSMPlus.h | 2 +- .../oneEquationTurbulenceModelLaxFriedrichs.h | 2 +- .../oneEquationTurbulenceModelStegerWarming.h | 2 +- .../one-equation-model/oneEquationTurbulenceModelVanLeer.h | 2 +- .../Two-Equation-turbulence-model/AUSM+/AUSMPlus.h | 2 +- .../Lax-Friedrichs/LaxFridrichs.h | 2 +- .../Steger-Warming/StegerWarming.h | 2 +- .../Two-Equation-turbulence-model/VanLeer/VanLeer.h | 2 +- .../KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.h | 4 ++-- .../KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.h | 4 ++-- .../KEPsilon-model/twoEquationTurbulenceModelStegerWarming.h | 4 ++-- .../KEPsilon-model/twoEquationTurbulenceModelVanLeer.h | 4 ++-- .../KOmega-model/twoEquationTurbulenceModelAUSMPlus.h | 2 +- .../KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h | 2 +- .../KOmega-model/twoEquationTurbulenceModelStegerWarming.h | 2 +- .../KOmega-model/twoEquationTurbulenceModelVanLeer.h | 2 +- 16 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.h index fa1dc84d4..3b46c2004 100644 --- a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.h +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelAUSMPlus.h @@ -5,7 +5,7 @@ #include #include #include "oneEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/One-Equation-Turbulence-Model/AUSM+/AUSMPlus.h" +#include "DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlus.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.h index 924a08337..8a3611b53 100644 --- a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.h +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelLaxFriedrichs.h @@ -5,7 +5,7 @@ #include #include #include "oneEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/One-Equation-Turbulence-Model/Lax-Friedrichs/LaxFridrichs.h" +#include "DifferentialOperators/One-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.h index 4df2195b0..7a8798e12 100644 --- a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.h +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelStegerWarming.h @@ -5,7 +5,7 @@ #include #include #include "oneEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/One-Equation-Turbulence-Model/Steger-Warming/StegerWarming.h" +#include "DifferentialOperators/One-Equation-turbulence-model/Steger-Warming/StegerWarming.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" diff --git a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h index eace7dc45..76abfba71 100644 --- a/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h +++ b/src/Examples/turbulent-flows/one-equation-model/oneEquationTurbulenceModelVanLeer.h @@ -5,7 +5,7 @@ #include #include #include "oneEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/One-Equation-Turbulence-Model/VanLeer/VanLeer.h" +#include "DifferentialOperators/One-Equation-turbulence-model/VanLeer/VanLeer.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h index 871edff20..192a584a5 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h @@ -23,7 +23,7 @@ #include "AUSMPlusTurbulentEnergy.h" #include "AUSMPlusDisipation.h" -#include "Examples/turbulent-flows/two-equation-model/KEpsilon-model/DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" +#include "Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h" namespace TNL { diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h index 52761a1c0..305a9fb88 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h @@ -23,7 +23,7 @@ #include "LaxFridrichsTurbulentEnergy.h" #include "LaxFridrichsDisipation.h" -#include "Examples/turbulent-flows/two-equation-model/KEpsilon-model/DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" +#include "Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h" namespace TNL { diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h index 5575bf5ac..dd314493d 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h @@ -23,7 +23,7 @@ #include "StegerWarmingTurbulentEnergy.h" #include "StegerWarmingDisipation.h" -#include "Examples/turbulent-flows/two-equation-model/KEpsilon-model/DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" +#include "Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h" namespace TNL { diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h index cd0a07043..58edd4ae9 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h @@ -23,7 +23,7 @@ #include "VanLeerTurbulentEnergy.h" #include "VanLeerDisipation.h" -#include "Examples/turbulent-flows/two-equation-model/KEpsilon-model/DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" +#include "Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h" namespace TNL { diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.h index 2d831bdb0..6b5cf4297 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelAUSMPlus.h @@ -5,7 +5,7 @@ #include #include #include "twoEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/Two-Equation-Turbulence-Model/AUSM+/AUSMPlus.h" +#include "DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" @@ -15,7 +15,7 @@ #include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" #include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" #include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" -#include "DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" +#include "DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h" using namespace TNL; diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.h index 2448756c9..0c1668882 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelLaxFriedrichs.h @@ -5,7 +5,7 @@ #include #include #include "twoEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/Two-Equation-Turbulence-Model/Lax-Friedrichs/LaxFridrichs.h" +#include "DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" @@ -15,7 +15,7 @@ #include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" #include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" #include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" -#include "DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" +#include "DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h" using namespace TNL; diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.h index efcb66351..511d7a5e1 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelStegerWarming.h @@ -5,7 +5,7 @@ #include #include #include "twoEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/Two-Equation-Turbulence-Model/Steger-Warming/StegerWarming.h" +#include "DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" @@ -15,7 +15,7 @@ #include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" #include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" #include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" -#include "DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" +#include "DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h" using namespace TNL; diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.h index 7dd9821c5..d03d38ce4 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/twoEquationTurbulenceModelVanLeer.h @@ -5,7 +5,7 @@ #include #include #include "twoEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/Two-Equation-Turbulence-Model/VanLeer/VanLeer.h" +#include "DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" @@ -15,7 +15,7 @@ #include "BoundaryConditions/BoilerModel/BoundaryConditionsBoilerModel.h" #include "BoundaryConditions/Dirichlet/BoundaryConditionsDirichlet.h" #include "BoundaryConditions/Neumann/BoundaryConditionsNeumann.h" -#include "DifferentialOperatorsRightHandSide/KEpsilonRightHandSide/KEpsilonOperatorRightHandSide.h" +#include "DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonOperatorRightHandSide.h" using namespace TNL; diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h index e79e14d2c..51d4d574e 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelAUSMPlus.h @@ -5,7 +5,7 @@ #include #include #include "twoEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/Two-Equation-Turbulence-Model/AUSM+/AUSMPlus.h" +#include "DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlus.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h index 45d4d996d..954033314 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelLaxFriedrichs.h @@ -5,7 +5,7 @@ #include #include #include "twoEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/Two-Equation-Turbulence-Model/Lax-Friedrichs/LaxFridrichs.h" +#include "DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.h index b1ea7746e..81ee70215 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelStegerWarming.h @@ -5,7 +5,7 @@ #include #include #include "twoEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/Two-Equation-Turbulence-Model/Steger-Warming/StegerWarming.h" +#include "DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarming.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h index cba2a3a06..2bf88fafe 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/twoEquationTurbulenceModelVanLeer.h @@ -5,7 +5,7 @@ #include #include #include "twoEquationTurbulenceModelProblem.h" -#include "DifferentialOperators/Two-Equation-Turbulence-Model/VanLeer/VanLeer.h" +#include "DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeer.h" #include "flowsRhs.h" #include "flowsBuildConfigTag.h" -- GitLab From e60319fe7e5025875090e5db995e4a6927cf8b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Fri, 26 Apr 2019 22:51:09 +0200 Subject: [PATCH 26/28] minor repairs --- .../MomentumXBoundaryConditionBoilerModel.h | 2 +- .../MomentumZBoundaryConditionBoilerModel.h | 8 +- .../MomentumXBoundaryConditionBoilerModel.h | 2 +- .../MomentumZBoundaryConditionBoilerModel.h | 8 +- ...KolmogorovMomentumXOperatorRightHandSide.h | 10 +- ...KolmogorovMomentumZOperatorRightHandSide.h | 12 +- ...orovTurbulentEnergyOperatorRightHandSide.h | 24 ++-- .../MomentumXBoundaryConditionBoilerModel.h | 2 +- .../MomentumZBoundaryConditionBoilerModel.h | 8 +- .../AUSM+/AUSMPlusTurbulentEnergy.h | 1 + .../Lax-Friedrichs/LaxFridrichs.h | 1 + .../LaxFridrichsTurbulentEnergy.h | 5 + .../StegerWarmingTurbulentEnergy.h | 1 + .../VanLeer/VanLeerTurbulentEnergy.h | 1 + .../KEpsilonDisipationOperatorRightHandSide.h | 103 ++++++++++++++---- .../KEpsilonMomentumXOperatorRightHandSide.h | 10 +- .../KEpsilonMomentumZOperatorRightHandSide.h | 12 +- ...ilonTurbulentEnergyOperatorRightHandSide.h | 59 +++++++--- .../MomentumXBoundaryConditionBoilerModel.h | 2 +- .../MomentumZBoundaryConditionBoilerModel.h | 8 +- .../KOmegaDisipationOperatorRightHandSide.h | 83 +++++++++++--- .../KOmegaMomentumXOperatorRightHandSide.h | 10 +- .../KOmegaMomentumZOperatorRightHandSide.h | 12 +- ...megaTurbulentEnergyOperatorRightHandSide.h | 24 ++-- .../MomentumXBoundaryConditionBoilerModel.h | 2 +- .../MomentumZBoundaryConditionBoilerModel.h | 8 +- .../PrandtlMomentumXOperatorRightHandSide.h | 10 +- .../PrandtlMomentumZOperatorRightHandSide.h | 12 +- .../zero-equation-model/Getter.h | 3 - 29 files changed, 296 insertions(+), 147 deletions(-) diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h index 65648c389..893815913 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -392,7 +392,7 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, // The following line is commented to avoid compiler warning //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] diff --git a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h index 625b74585..ee40b1b74 100644 --- a/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h +++ b/src/Examples/flows/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -492,7 +492,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) @@ -550,7 +550,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) @@ -611,13 +611,13 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h index 65648c389..893815913 100644 --- a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -392,7 +392,7 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, // The following line is commented to avoid compiler warning //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] diff --git a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h index 625b74585..ee40b1b74 100644 --- a/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h +++ b/src/Examples/turbulent-flows/one-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -492,7 +492,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) @@ -550,7 +550,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) @@ -611,13 +611,13 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumXOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumXOperatorRightHandSide.h index 0e76c056d..d672a2888 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumXOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumXOperatorRightHandSide.h @@ -223,7 +223,7 @@ class PrandtlKolmogorovMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device // t_11_x + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west ) * hxSquareInverse - - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 + 2.0 / 3.0 * ( density_east * turbulentEnergy_east @@ -231,7 +231,7 @@ class PrandtlKolmogorovMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device ) * hxInverse / 2 ) // t_21_y - + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast + velocity_y_southWest ) + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south ) * hySquareInverse @@ -403,9 +403,9 @@ class PrandtlKolmogorovMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_west ) * hxSquareInverse - - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest + velocity_z_downWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest - velocity_z_downWest ) ) * hxInverse * hzInverse / 4 + 2.0 / 3.0 * ( density_east * turbulentEnergy_east @@ -415,7 +415,7 @@ class PrandtlKolmogorovMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, // t_21_y + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 - + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north - turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south ) * hySquareInverse ) // t_31_z diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumZOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumZOperatorRightHandSide.h index cf642efad..b4b196369 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumZOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovMomentumZOperatorRightHandSide.h @@ -297,21 +297,21 @@ class PrandtlKolmogorovMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, // t_13_x + ( ( turbulentViscosity_east * velocity_z_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_west ) * hxSquareInverse - + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest + velocity_x_downWest ) ) + + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest - velocity_x_downWest ) ) * hxInverse * hzInverse / 4 ) // t_23_y - + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + + ( ( turbulentViscosity_north * ( velocity_y_upNorth - velocity_y_downNorth ) - turbulentViscosity_south * ( velocity_y_upSouth - velocity_y_downSouth ) ) * hyInverse * hzInverse / 4 - + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + + ( turbulentViscosity_north * velocity_z_north - (turbulentViscosity_north + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_south ) * hySquareInverse ) // t_33_z - + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + + ( 4.0 / 3.0 * ( turbulentViscosity_up * velocity_z_up - ( turbulentViscosity_up + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_down ) * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + - 2.0 / 3.0 * ( turbulentViscosity_up * velocity_y_upNorth - turbulentViscosity_down * velocity_y_downNorth - turbulentViscosity_up * velocity_y_upSouth + turbulentViscosity_down * velocity_y_downSouth ) * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + - 2.0 / 3.0 * ( turbulentViscosity_up * velocity_x_upEast - turbulentViscosity_down * velocity_x_downEast - turbulentViscosity_up * velocity_x_upWest + turbulentViscosity_down * velocity_x_downWest ) * hxInverse * hzInverse / 4 + 2.0 / 3.0 * ( density_up * turbulentEnergy_up diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h index 8dc13ed34..3e7e370b1 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperatorsRightHandSide/PrandtlKolmogorovRightHandSide/PrandtlKolmogorovTurbulentEnergyOperatorRightHandSide.h @@ -193,8 +193,8 @@ class PrandtlKolmogorovTurbulentEnergyRightHandSide< Meshes::Grid< 1, MeshReal, + this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) * hxSquareInverse - + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_east + turbulentEnergy_west * turbulentViscosity_center ) * hxSquareInverse / this->sigmaK; } @@ -323,15 +323,15 @@ class PrandtlKolmogorovTurbulentEnergyRightHandSide< Meshes::Grid< 2, MeshReal, + this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) * hxSquareInverse - + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_east + turbulentEnergy_west * turbulentViscosity_center ) * hxSquareInverse / this->sigmaK + this->dynamicalViscosity * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) * hySquareInverse - + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_north + turbulentEnergy_south * turbulentViscosity_center ) * hySquareInverse / this->sigmaK; } @@ -533,22 +533,22 @@ class PrandtlKolmogorovTurbulentEnergyRightHandSide< Meshes::Grid< 3, MeshReal, + this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) * hxSquareInverse - + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_east + turbulentEnergy_west * turbulentViscosity_center ) * hxSquareInverse / this->sigmaK + this->dynamicalViscosity * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) * hySquareInverse - + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_north + turbulentEnergy_south * turbulentViscosity_center ) * hySquareInverse / this->sigmaK + this->dynamicalViscosity * ( turbulentEnergy_up - 2 * turbulentEnergy_center + turbulentEnergy_down ) * hySquareInverse - + ( turbulentEnergy_up * turbulentViscosity_up - turbulentEnergy_center * turbulentViscosity_down - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_down * turbulentViscosity_down + + ( turbulentEnergy_up * turbulentViscosity_up - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_up + turbulentEnergy_down * turbulentViscosity_center ) * hySquareInverse / this->sigmaK; } diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h index 65648c389..893815913 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -392,7 +392,7 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, // The following line is commented to avoid compiler warning //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h index 625b74585..ee40b1b74 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -492,7 +492,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) @@ -550,7 +550,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) @@ -611,13 +611,13 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h index ed24d118b..dedb7e7ac 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h @@ -71,6 +71,7 @@ class AUSMPlusTurbulentEnergyBase void setDensity( const MeshFunctionPointer& density ) { this->density = density; + this->rightHandSide.setDensity(density); }; void setDynamicalViscosity( const RealType& dynamicalViscosity ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h index 305a9fb88..1167c318b 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichs.h @@ -143,6 +143,7 @@ class LaxFridrichs this->momentumYOperatorPointer->setDensity( density ); this->momentumZOperatorPointer->setDensity( density ); this->energyOperatorPointer->setDensity( density ); + this->turbulentEnergyOperatorPointer->setDensity( density ); this->disipationOperatorPointer->setDensity( density ); } diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h index 02c03dffa..5c6c9b15f 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Lax-Friedrichs/LaxFridrichsTurbulentEnergy.h @@ -60,6 +60,11 @@ class LaxFridrichsTurbulentEnergyBase this->velocity = velocity; this->rightHandSide.setVelocity(velocity); }; + + void setDensity( const MeshFunctionPointer& density ) + { + this->rightHandSide.setDensity(density); + }; void setArtificialViscosity( const RealType& artificialViscosity ) { diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h index 20bff760a..83b7f3fab 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/Steger-Warming/StegerWarmingTurbulentEnergy.h @@ -70,6 +70,7 @@ class StegerWarmingTurbulentEnergyBase void setDensity( const MeshFunctionPointer& density ) { + this->rightHandSide.setDensity(density); this->density = density; }; diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h index 3a959ac91..9d6fd09d0 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/VanLeer/VanLeerTurbulentEnergy.h @@ -70,6 +70,7 @@ class VanLeerTurbulentEnergyBase void setDensity( const MeshFunctionPointer& density ) { + this->rightHandSide.setDensity(density); this->density = density; }; diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h index 6c52ebcd2..26fddb13d 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h @@ -177,20 +177,31 @@ class KEpsilonDisipationRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIn const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + if( ! turbulentEnergy_center == 0.0 ) return this->dynamicalViscosity * ( disipation_east - 2 * disipation_center + disipation_west ) * hxSquareInverse - + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_west - - disipation_center * turbulentViscosity_center + disipation_west * turbulentViscosity_west + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_east + disipation_west * turbulentViscosity_center ) * hxSquareInverse / this->sigmaEpsilon - - this->viscosityConstant1 * disipation_center / turbulentEnergy_center - * 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 - * turbulentViscosity_center + + this->viscosityConstant1 * disipation_center / turbulentEnergy_center + * ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + * turbulentViscosity_center + - 2.0 / 3.0 * density_center * turbulentEnergy_center + ) * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 - this->viscosityConstant2 * density_center * disipation_center * disipation_center / turbulentEnergy_center; + else + return + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_east + disipation_west * turbulentViscosity_center + ) * hxSquareInverse / this->sigmaEpsilon; } /*template< typename MeshEntity > @@ -298,30 +309,33 @@ class KEpsilonDisipationRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIn const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + if( ! turbulentEnergy_center == 0.0 ) return this->dynamicalViscosity * ( disipation_east - 2 * disipation_center + disipation_west ) * hxSquareInverse - + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_west - - disipation_center * turbulentViscosity_center + disipation_west * turbulentViscosity_west + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_east + disipation_west * turbulentViscosity_center ) * hxSquareInverse / this->sigmaEpsilon + this->dynamicalViscosity * ( disipation_north - 2 * disipation_center + disipation_south ) * hySquareInverse - + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_south - - disipation_center * turbulentViscosity_center + disipation_south * turbulentViscosity_south - ) * hySquareInverse / this->sigmaEpsioln + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_north + disipation_south * turbulentViscosity_center + ) * hySquareInverse / this->sigmaEpsilon - - this->viscosityConstant1 * disipation_center / turbulentEnergy_center + + this->viscosityConstant1 * disipation_center / turbulentEnergy_center * ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 ) * turbulentViscosity_center + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * density_center * turbulentEnergy_center * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 - ) * turbulentViscosity_center + ) * turbulentViscosity_center * ( velocity_y_east - velocity_y_west ) * hxInverse / 2 + ( ( velocity_y_east - velocity_y_west ) * hxInverse / 2 @@ -331,11 +345,29 @@ class KEpsilonDisipationRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIn + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 - ) * turbulentViscosity_center + ) * turbulentViscosity_center * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * density_center * turbulentEnergy_center + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + ) - this->viscosityConstant2 * density_center * disipation_center * disipation_center / turbulentEnergy_center; + else + return + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_east + disipation_west * turbulentViscosity_center + ) * hxSquareInverse / this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_north - 2 * disipation_center + disipation_south ) + * hySquareInverse + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_north + disipation_south * turbulentViscosity_center + ) * hySquareInverse / this->sigmaEpsilon; } /*template< typename MeshEntity > @@ -495,34 +527,37 @@ class KEpsilonDisipationRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIn const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + if( ! turbulentEnergy_center == 0.0 ) return this->dynamicalViscosity * ( disipation_east - 2 * disipation_center + disipation_west ) * hxSquareInverse - + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_west - - disipation_center * turbulentViscosity_center + disipation_west * turbulentViscosity_west + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_east + disipation_west * turbulentViscosity_center ) * hxSquareInverse / this->sigmaEpsilon + this->dynamicalViscosity * ( disipation_north - 2 * disipation_center + disipation_south ) * hySquareInverse - + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_south - - disipation_center * turbulentViscosity_center + disipation_south * turbulentViscosity_south + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_north + disipation_south * turbulentViscosity_center ) * hySquareInverse / this->sigmaEpsilon + this->dynamicalViscosity * ( disipation_up - 2 * disipation_center + disipation_down ) * hySquareInverse - + ( disipation_up * turbulentViscosity_up - disipation_center * turbulentViscosity_down - - disipation_center * turbulentViscosity_center + disipation_down * turbulentViscosity_down + + ( disipation_up * turbulentViscosity_up - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_up + disipation_down * turbulentViscosity_center ) * hySquareInverse / this->sigmaEpsilon - - this->viscosityConstant1 * disipation_center / turbulentEnergy_center + + this->viscosityConstant1 * disipation_center / turbulentEnergy_center * ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 - 2.0 / 3.0 * ( velocity_y_north - velocity_x_south ) * hyInverse / 2 - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 ) * turbulentViscosity_center * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * density_center * turbulentEnergy_center + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 @@ -544,6 +579,8 @@ class KEpsilonDisipationRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIn - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 ) * turbulentViscosity_center * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * density_center * turbulentEnergy_center + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + ( ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + ( velocity_z_north - velocity_z_south ) * hyInverse / 2 @@ -565,9 +602,33 @@ class KEpsilonDisipationRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIn - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 ) * turbulentViscosity_center * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + - 2.0 / 3.0 * density_center * turbulentEnergy_center + * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 ) - - this->viscosityConstant2 * density_center * disipation_center * disipation_center / turbulentEnergy_center; + - this->viscosityConstant2 * density_center * disipation_center * disipation_center / turbulentEnergy_center; + else + return + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_east + disipation_west * turbulentViscosity_center + ) * hxSquareInverse / this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_north - 2 * disipation_center + disipation_south ) + * hySquareInverse + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_north + disipation_south * turbulentViscosity_center + ) * hySquareInverse / this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_up - 2 * disipation_center + disipation_down ) + * hySquareInverse + + ( disipation_up * turbulentViscosity_up - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_up + disipation_down * turbulentViscosity_center + ) * hySquareInverse / this->sigmaEpsilon; } /*template< typename MeshEntity > diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumXOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumXOperatorRightHandSide.h index a213cdc72..74d0b479f 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumXOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumXOperatorRightHandSide.h @@ -223,7 +223,7 @@ class KEpsilonMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshInd // t_11_x + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west ) * hxSquareInverse - - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 + 2.0 / 3.0 * ( density_east * turbulentEnergy_east @@ -231,7 +231,7 @@ class KEpsilonMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshInd ) * hxInverse / 2 ) // t_21_y - + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast + velocity_y_southWest ) + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south ) * hySquareInverse @@ -403,9 +403,9 @@ class KEpsilonMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshInde + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_west ) * hxSquareInverse - - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest + velocity_z_downWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest - velocity_z_downWest ) ) * hxInverse * hzInverse / 4 + 2.0 / 3.0 * ( density_east * turbulentEnergy_east @@ -415,7 +415,7 @@ class KEpsilonMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshInde // t_21_y + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 - + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north - turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south ) * hySquareInverse ) // t_31_z diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumZOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumZOperatorRightHandSide.h index 0ff824ae1..ec9bb9e76 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumZOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonMomentumZOperatorRightHandSide.h @@ -297,21 +297,21 @@ class KEpsilonMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshInde // t_13_x + ( ( turbulentViscosity_east * velocity_z_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_west ) * hxSquareInverse - + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest + velocity_x_downWest ) ) + + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest - velocity_x_downWest ) ) * hxInverse * hzInverse / 4 ) // t_23_y - + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + + ( ( turbulentViscosity_north * ( velocity_y_upNorth - velocity_y_downNorth ) - turbulentViscosity_south * ( velocity_y_upSouth - velocity_y_downSouth ) ) * hyInverse * hzInverse / 4 - + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + + ( turbulentViscosity_north * velocity_z_north - (turbulentViscosity_north + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_south ) * hySquareInverse ) // t_33_z - + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + + ( 4.0 / 3.0 * ( turbulentViscosity_up * velocity_z_up - ( turbulentViscosity_up + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_down ) * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + - 2.0 / 3.0 * ( turbulentViscosity_up * velocity_y_upNorth - turbulentViscosity_down * velocity_y_downNorth - turbulentViscosity_up * velocity_y_upSouth + turbulentViscosity_down * velocity_y_downSouth ) * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + - 2.0 / 3.0 * ( turbulentViscosity_up * velocity_x_upEast - turbulentViscosity_down * velocity_x_downEast - turbulentViscosity_up * velocity_x_upWest + turbulentViscosity_down * velocity_x_downWest ) * hxInverse * hzInverse / 4 + 2.0 / 3.0 * ( density_up * turbulentEnergy_up diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonTurbulentEnergyOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonTurbulentEnergyOperatorRightHandSide.h index d08930d62..0f3678c47 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonTurbulentEnergyOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonTurbulentEnergyOperatorRightHandSide.h @@ -70,12 +70,19 @@ class KEpsilonTurbulentEnergyRightHandSideBase { this->turbulentEnergy = turbulentEnergy; } + + void setDensity( const MeshFunctionPointer& density ) + { + this->density = density; + } protected: MeshFunctionPointer turbulentViscosity; MeshFunctionPointer turbulentEnergy; + + MeshFunctionPointer density; VelocityFieldPointer velocity; @@ -137,6 +144,8 @@ class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, M const RealType& turbulentViscosity_west = this->turbulentViscosity.template getData< DeviceType >()[ west ]; const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; @@ -149,12 +158,14 @@ class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, M this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) * hxSquareInverse - + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_east + turbulentEnergy_west * turbulentViscosity_center ) * hxSquareInverse / this->sigmaK - - - 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + + ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 * turbulentViscosity_center + - 2.0 / 3.0 * density_center * turbulentEnergy_center + ) * ( velocity_x_east - velocity_x_west ) * hxInverse / 2; } @@ -228,6 +239,8 @@ class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, M const RealType& turbulentViscosity_east = this->turbulentViscosity.template getData< DeviceType >()[ east ]; const RealType& turbulentViscosity_north = this->turbulentViscosity.template getData< DeviceType >()[ north ]; const RealType& turbulentViscosity_south = this->turbulentViscosity.template getData< DeviceType >()[ south ]; + + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; @@ -259,20 +272,22 @@ class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, M this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) * hxSquareInverse - + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_east + turbulentEnergy_west * turbulentViscosity_center ) * hxSquareInverse / this->sigmaK + this->dynamicalViscosity * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) * hySquareInverse - + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_north + turbulentEnergy_south * turbulentViscosity_center ) * hySquareInverse / this->sigmaK - - ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 ) * turbulentViscosity_center + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * density_center * turbulentEnergy_center * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 @@ -287,7 +302,9 @@ class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, M + ( 4.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 - ) * turbulentViscosity_center + ) * turbulentViscosity_center + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * density_center * turbulentEnergy_center * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 ); @@ -378,6 +395,8 @@ class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, M const RealType& turbulentViscosity_up = this->turbulentViscosity.template getData< DeviceType >()[ up ]; const RealType& turbulentViscosity_down = this->turbulentViscosity.template getData< DeviceType >()[ down ]; + const RealType& density_center = this->density.template getData< DeviceType >()[ center ]; + const RealType& turbulentEnergy_center = this->turbulentEnergy.template getData< DeviceType >()[ center ]; const RealType& turbulentEnergy_west = this->turbulentEnergy.template getData< DeviceType >()[ west ]; const RealType& turbulentEnergy_east = this->turbulentEnergy.template getData< DeviceType >()[ east ]; @@ -438,29 +457,31 @@ class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, M this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) * hxSquareInverse - + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_east + turbulentEnergy_west * turbulentViscosity_center ) * hxSquareInverse / this->sigmaK + this->dynamicalViscosity * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) * hySquareInverse - + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_north + turbulentEnergy_south * turbulentViscosity_center ) * hySquareInverse / this->sigmaK + this->dynamicalViscosity * ( turbulentEnergy_up - 2 * turbulentEnergy_center + turbulentEnergy_down ) * hySquareInverse - + ( turbulentEnergy_up * turbulentViscosity_up - turbulentEnergy_center * turbulentViscosity_down - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_down * turbulentViscosity_down + + ( turbulentEnergy_up * turbulentViscosity_up - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_up + turbulentEnergy_down * turbulentViscosity_center ) * hySquareInverse / this->sigmaK - - ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + + ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 - 2.0 / 3.0 * ( velocity_y_north - velocity_x_south ) * hyInverse / 2 - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 ) * turbulentViscosity_center * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + - 2.0 / 3.0 * density_center * turbulentEnergy_center + * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 + ( ( velocity_x_north - velocity_x_south ) * hyInverse / 2 + ( velocity_y_east - velocity_y_west ) * hxInverse / 2 @@ -482,6 +503,8 @@ class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, M - 2.0 / 3.0 * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 ) * turbulentViscosity_center * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + - 2.0 / 3.0 * density_center * turbulentEnergy_center + * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 + ( ( velocity_y_up - velocity_y_down ) * hzInverse / 2 + ( velocity_z_north - velocity_z_south ) * hyInverse / 2 @@ -503,6 +526,8 @@ class KEpsilonTurbulentEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, M - 2.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 ) * turbulentViscosity_center * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 + - 2.0 / 3.0 * density_center * turbulentEnergy_center + * ( velocity_z_up - velocity_z_down ) * hzInverse / 2 ); } diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h index 65648c389..893815913 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -392,7 +392,7 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, // The following line is commented to avoid compiler warning //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h index 625b74585..ee40b1b74 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -492,7 +492,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) @@ -550,7 +550,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) @@ -611,13 +611,13 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaDisipationOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaDisipationOperatorRightHandSide.h index ffd928cca..892699db9 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaDisipationOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaDisipationOperatorRightHandSide.h @@ -177,6 +177,7 @@ class KOmegaDisipationRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshInde const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; + if( ! turbulentEnergy_center == 0.0 ) return this->alpha * disipation_center / turbulentEnergy_center * 4.0 / 3.0 *( velocity_x_east - 2 * velocity_x_center + velocity_x_west @@ -189,8 +190,19 @@ class KOmegaDisipationRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshInde this->dynamicalViscosity * ( disipation_east - 2 * disipation_center + disipation_west ) * hxSquareInverse - + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_west - - disipation_center * turbulentViscosity_center + disipation_west * turbulentViscosity_west + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_east + disipation_west * turbulentViscosity_center + ) * hxSquareInverse * this->sigmaEpsilon; + else + return + - + this->beta * disipation_center * disipation_center + + + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_east + disipation_west * turbulentViscosity_center ) * hxSquareInverse * this->sigmaEpsilon; } @@ -299,6 +311,7 @@ class KOmegaDisipationRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshInde const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; + if( ! turbulentEnergy_center == 0.0 ) return this->alpha * disipation_center / turbulentEnergy_center * ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 - 2.0 / 3.0 * ( velocity_y_north - velocity_y_south ) * hyInverse / 2 @@ -326,15 +339,33 @@ class KOmegaDisipationRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshInde this->dynamicalViscosity * ( disipation_north - 2 * disipation_center + disipation_south ) * hySquareInverse - + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_south - - disipation_center * turbulentViscosity_center + disipation_south * turbulentViscosity_south + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_north + disipation_south * turbulentViscosity_center ) * hySquareInverse * this->sigmaEpsilon + this->dynamicalViscosity * ( disipation_east - 2 * disipation_center + disipation_west ) * hxSquareInverse - + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_west - - disipation_center * turbulentViscosity_center + disipation_west * turbulentViscosity_west + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_east + disipation_west * turbulentViscosity_center + ) * hxSquareInverse * this->sigmaEpsilon; + else + return + - + this->beta * disipation_center * disipation_center + + + this->dynamicalViscosity + * ( disipation_north - 2 * disipation_center + disipation_south ) + * hySquareInverse + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_north + disipation_south * turbulentViscosity_center + ) * hySquareInverse * this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_east + disipation_west * turbulentViscosity_center ) * hxSquareInverse * this->sigmaEpsilon; } @@ -495,6 +526,7 @@ class KOmegaDisipationRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshInde const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; + if( ! turbulentEnergy_center == 0.0 ) return this->alpha * disipation_center / turbulentEnergy_center // 3D uT_11_x * ( ( 4.0 / 3.0 * ( velocity_x_east - velocity_x_west ) * hxInverse / 2 @@ -551,23 +583,48 @@ class KOmegaDisipationRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshInde this->dynamicalViscosity * ( disipation_east - 2 * disipation_center + disipation_west ) * hxSquareInverse - + ( disipation_east * turbulentViscosity_east - disipation_center * disipation_west - - disipation_center * turbulentViscosity_center + disipation_west * disipation_west + + ( disipation_east * turbulentViscosity_east - disipation_center * disipation_center + - disipation_center * turbulentViscosity_east + disipation_west * disipation_center + ) * hxSquareInverse * this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_north - 2 * disipation_center + disipation_south ) + * hySquareInverse + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_north + disipation_south * turbulentViscosity_center + ) * hySquareInverse * this->sigmaEpsilon + + + this->dynamicalViscosity + * ( disipation_up - 2 * disipation_center + disipation_down ) + * hySquareInverse + + ( disipation_up * turbulentViscosity_up - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_up + disipation_down * turbulentViscosity_center + ) * hySquareInverse * this->sigmaEpsilon; + else + return + - + this->beta * disipation_center * disipation_center + + + this->dynamicalViscosity + * ( disipation_east - 2 * disipation_center + disipation_west ) + * hxSquareInverse + + ( disipation_east * turbulentViscosity_east - disipation_center * disipation_center + - disipation_center * turbulentViscosity_east + disipation_west * disipation_center ) * hxSquareInverse * this->sigmaEpsilon + this->dynamicalViscosity * ( disipation_north - 2 * disipation_center + disipation_south ) * hySquareInverse - + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_south - - disipation_center * turbulentViscosity_center + disipation_south * turbulentViscosity_south + + ( disipation_north * turbulentViscosity_north - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_north + disipation_south * turbulentViscosity_center ) * hySquareInverse * this->sigmaEpsilon + this->dynamicalViscosity * ( disipation_up - 2 * disipation_center + disipation_down ) * hySquareInverse - + ( disipation_up * turbulentViscosity_up - disipation_center * turbulentViscosity_down - - disipation_center * turbulentViscosity_center + disipation_down * turbulentViscosity_down - ) * hySquareInverse * this->sigmaEpsilon; + + ( disipation_up * turbulentViscosity_up - disipation_center * turbulentViscosity_center + - disipation_center * turbulentViscosity_up + disipation_down * turbulentViscosity_center + ) * hySquareInverse * this->sigmaEpsilon; } /*template< typename MeshEntity > diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumXOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumXOperatorRightHandSide.h index fc61a5142..acbacbe43 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumXOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumXOperatorRightHandSide.h @@ -223,7 +223,7 @@ class KOmegaMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex // t_11_x + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west ) * hxSquareInverse - - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 + 2.0 / 3.0 * ( density_east * turbulentEnergy_east @@ -231,7 +231,7 @@ class KOmegaMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIndex ) * hxInverse / 2 ) // t_21_y - + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast + velocity_y_southWest ) + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south ) * hySquareInverse @@ -403,9 +403,9 @@ class KOmegaMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_west ) * hxSquareInverse - - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest + velocity_z_downWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest - velocity_z_downWest ) ) * hxInverse * hzInverse / 4 + 2.0 / 3.0 * ( density_east * turbulentEnergy_east @@ -415,7 +415,7 @@ class KOmegaMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex // t_21_y + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 - + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north - turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south ) * hySquareInverse ) // t_31_z diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumZOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumZOperatorRightHandSide.h index 6b92ad3c5..f6087c402 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumZOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaMomentumZOperatorRightHandSide.h @@ -297,21 +297,21 @@ class KOmegaMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex // t_13_x + ( ( turbulentViscosity_east * velocity_z_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_west ) * hxSquareInverse - + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest + velocity_x_downWest ) ) + + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest - velocity_x_downWest ) ) * hxInverse * hzInverse / 4 ) // t_23_y - + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + + ( ( turbulentViscosity_north * ( velocity_y_upNorth - velocity_y_downNorth ) - turbulentViscosity_south * ( velocity_y_upSouth - velocity_y_downSouth ) ) * hyInverse * hzInverse / 4 - + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + + ( turbulentViscosity_north * velocity_z_north - (turbulentViscosity_north + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_south ) * hySquareInverse ) // t_33_z - + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + + ( 4.0 / 3.0 * ( turbulentViscosity_up * velocity_z_up - ( turbulentViscosity_up + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_down ) * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + - 2.0 / 3.0 * ( turbulentViscosity_up * velocity_y_upNorth - turbulentViscosity_down * velocity_y_downNorth - turbulentViscosity_up * velocity_y_upSouth + turbulentViscosity_down * velocity_y_downSouth ) * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + - 2.0 / 3.0 * ( turbulentViscosity_up * velocity_x_upEast - turbulentViscosity_down * velocity_x_downEast - turbulentViscosity_up * velocity_x_upWest + turbulentViscosity_down * velocity_x_downWest ) * hxInverse * hzInverse / 4 + 2.0 / 3.0 * ( density_up * turbulentEnergy_up diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaTurbulentEnergyOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaTurbulentEnergyOperatorRightHandSide.h index de2a655ce..696018bf3 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaTurbulentEnergyOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperatorsRightHandSide/KOmegaRightHandSide/KOmegaTurbulentEnergyOperatorRightHandSide.h @@ -172,8 +172,8 @@ class KOmegaTurbulentEnergyRightHandSide< Meshes::Grid< 1, MeshReal, Device, Mes this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) * hxSquareInverse - + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_east + turbulentEnergy_west * turbulentViscosity_center ) * hxSquareInverse * this->sigmaK; } @@ -302,15 +302,15 @@ class KOmegaTurbulentEnergyRightHandSide< Meshes::Grid< 2, MeshReal, Device, Mes this->dynamicalViscosity * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) * hySquareInverse - + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_north + turbulentEnergy_south * turbulentViscosity_center ) * hySquareInverse * this->sigmaK + this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) * hxSquareInverse - + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_east + turbulentEnergy_west * turbulentViscosity_center ) * hxSquareInverse * this->sigmaK; } @@ -512,22 +512,22 @@ class KOmegaTurbulentEnergyRightHandSide< Meshes::Grid< 3, MeshReal, Device, Mes this->dynamicalViscosity * ( turbulentEnergy_east - 2 * turbulentEnergy_center + turbulentEnergy_west ) * hxSquareInverse - + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_west - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_west * turbulentViscosity_west + + ( turbulentEnergy_east * turbulentViscosity_east - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_east + turbulentEnergy_west * turbulentViscosity_center ) * hxSquareInverse * this->sigmaK + this->dynamicalViscosity * ( turbulentEnergy_north - 2 * turbulentEnergy_center + turbulentEnergy_south ) * hySquareInverse - + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_south - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_south * turbulentViscosity_south + + ( turbulentEnergy_north * turbulentViscosity_north - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_north + turbulentEnergy_south * turbulentViscosity_center ) * hySquareInverse * this->sigmaK + this->dynamicalViscosity * ( turbulentEnergy_up - 2 * turbulentEnergy_center + turbulentEnergy_down ) * hySquareInverse - + ( turbulentEnergy_up * turbulentViscosity_up - turbulentEnergy_center * turbulentViscosity_down - - turbulentEnergy_center * turbulentViscosity_center + turbulentEnergy_down * turbulentViscosity_down + + ( turbulentEnergy_up * turbulentViscosity_up - turbulentEnergy_center * turbulentViscosity_center + - turbulentEnergy_center * turbulentViscosity_up + turbulentEnergy_down * turbulentViscosity_center ) * hySquareInverse * this->sigmaK; } diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h index 65648c389..893815913 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumXBoundaryConditionBoilerModel.h @@ -392,7 +392,7 @@ class MomentumXBoundaryConditionsBoilerModel< Meshes::Grid< 2, MeshReal, Device, // The following line is commented to avoid compiler warning //if( entity.getCoordinates().y() == entity.getMesh().getDimensions().y() - 1 ) { - return u[ neighborEntities.template getEntityIndex< 0, -1 >() ]; + return u[ neighborEntities.template getEntityIndex< 0, 0 >() ]; /*return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0 >()] * ( (* (* this->compressibleConservativeVariables->getMomentum())[ 0 ])[neighborEntities.template getEntityIndex< 0, -1 >()] diff --git a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h index 625b74585..ee40b1b74 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h +++ b/src/Examples/turbulent-flows/zero-equation-model/BoundaryConditions/BoilerModel/MomentumZBoundaryConditionBoilerModel.h @@ -492,7 +492,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::cos( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::sin( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) @@ -550,7 +550,7 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().y() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().y() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().y() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().y() - 1 ) ) @@ -611,13 +611,13 @@ class MomentumZBoundaryConditionsBoilerModel< Meshes::Grid< 3, MeshReal, Device, if( entity.getCoordinates().x() < 0.08 * std::sin( this->xYAngle ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); if ( entity.getCoordinates().x() > ( 1 - 0.08 * std::cos( this->xYAngle ) ) * ( entity.getMesh().getDimensions().x() - 1 ) ) return (* this->compressibleConservativeVariables->getDensity())[neighborEntities.template getEntityIndex< 0, 0, 0 >()] * ( - this->horizontalThrottleSpeed + this->horizontalThrottleSpeed * ( -1.0 ) * std::sin( this->zAngle ) ); return u[ neighborEntities.template getEntityIndex< 0, 0, 0 >() ]; diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumXOperatorRightHandSide.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumXOperatorRightHandSide.h index 200dcbc35..262ccb54f 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumXOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumXOperatorRightHandSide.h @@ -206,11 +206,11 @@ class PrandtlMomentumXRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshInde // t_11_x + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center) * velocity_x_center + turbulentViscosity_center * velocity_x_west ) * hxSquareInverse - - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 ) // t_21_y - + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast + velocity_y_southWest ) + + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south ) * hySquareInverse @@ -376,15 +376,15 @@ class PrandtlMomentumXRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex + ( 4.0 / 3.0 * ( turbulentViscosity_east * velocity_x_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_west ) * hxSquareInverse - - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest + velocity_y_southWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * ( velocity_y_northEast - velocity_y_southEast ) - turbulentViscosity_west * ( velocity_y_northWest - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 - - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest + velocity_z_downWest ) + - 2.0 / 3.0 * ( turbulentViscosity_east * (velocity_z_upEast - velocity_z_downEast ) - turbulentViscosity_west * ( velocity_z_upWest - velocity_z_downWest ) ) * hxInverse * hzInverse / 4 ) // t_21_y + ( ( turbulentViscosity_north * ( velocity_y_northEast - velocity_y_northWest ) - turbulentViscosity_south * ( velocity_y_southEast - velocity_y_southWest ) ) * hxInverse * hyInverse / 4 - + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north - turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south + + ( turbulentViscosity_north * velocity_x_north - ( turbulentViscosity_north + turbulentViscosity_center ) * velocity_x_center + turbulentViscosity_center * velocity_x_south ) * hySquareInverse ) // t_31_z diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumZOperatorRightHandSide.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumZOperatorRightHandSide.h index 78cc9062f..2504a870d 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumZOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperatorsRightHandSide/PrandtlRightHandSide/PrandtlMomentumZOperatorRightHandSide.h @@ -291,21 +291,21 @@ class PrandtlMomentumZRightHandSide< Meshes::Grid< 3,MeshReal, Device, MeshIndex // t_13_x + ( ( turbulentViscosity_east * velocity_z_east - ( turbulentViscosity_east + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_west ) * hxSquareInverse - + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest + velocity_x_downWest ) ) + + ( turbulentViscosity_east * ( velocity_x_upEast - velocity_x_downEast ) - turbulentViscosity_west * ( velocity_x_upWest - velocity_x_downWest ) ) * hxInverse * hzInverse / 4 ) // t_23_y - + ( ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + + ( ( turbulentViscosity_north * ( velocity_y_upNorth - velocity_y_downNorth ) - turbulentViscosity_south * ( velocity_y_upSouth - velocity_y_downSouth ) ) * hyInverse * hzInverse / 4 - + ( velocity_z_north - 2 * velocity_z_center + velocity_z_south ) + + ( turbulentViscosity_north * velocity_z_north - (turbulentViscosity_north + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_south ) * hySquareInverse ) // t_33_z - + ( 4.0 / 3.0 * ( velocity_z_up - 2 * velocity_z_center + velocity_z_down ) + + ( 4.0 / 3.0 * ( turbulentViscosity_up * velocity_z_up - ( turbulentViscosity_up + turbulentViscosity_center ) * velocity_z_center + turbulentViscosity_center * velocity_z_down ) * hzSquareInverse - - 2.0 / 3.0 * ( velocity_y_upNorth - velocity_y_downNorth - velocity_y_upSouth + velocity_y_downSouth ) + - 2.0 / 3.0 * ( turbulentViscosity_up * velocity_y_upNorth - turbulentViscosity_down * velocity_y_downNorth - turbulentViscosity_up * velocity_y_upSouth + turbulentViscosity_down * velocity_y_downSouth ) * hyInverse * hzInverse / 4 - - 2.0 / 3.0 * ( velocity_x_upEast - velocity_x_downEast - velocity_x_upWest + velocity_x_downWest ) + - 2.0 / 3.0 * ( turbulentViscosity_up * velocity_x_upEast - turbulentViscosity_down * velocity_x_downEast - turbulentViscosity_up * velocity_x_upWest + turbulentViscosity_down * velocity_x_downWest ) * hxInverse * hzInverse / 4 ); } diff --git a/src/Examples/turbulent-flows/zero-equation-model/Getter.h b/src/Examples/turbulent-flows/zero-equation-model/Getter.h index 612b53618..096ae165a 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/Getter.h +++ b/src/Examples/turbulent-flows/zero-equation-model/Getter.h @@ -252,9 +252,6 @@ class TurbulentViscosityGetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, const RealType& velocity_z_west = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ west ]; const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; - if( ! ( ( ( meshEntity.getCoordinates().x() == 0 ) || ( meshEntity.getCoordinates().x() == meshEntity.getMesh().getDimensions().x() - 1 ) ) - ||( ( meshEntity.getCoordinates().y() == 0 ) || ( meshEntity.getCoordinates().x() == meshEntity.getMesh().getDimensions().y() - 1 ) ) - ||( ( meshEntity.getCoordinates().z() == 0 ) || ( meshEntity.getCoordinates().x() == meshEntity.getMesh().getDimensions().z() - 1 ) ) ) ) return rho * this->mixingLength * this->mixingLength * ( ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 - ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 -- GitLab From 0d0354a7b3fe854c71f46824e690ca5fcd08fdd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Mon, 29 Apr 2019 00:43:24 +0200 Subject: [PATCH 27/28] bracket in Prandtl model for 3D turbulent viscosity --- .../zero-equation-model/Getter.h | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/Examples/turbulent-flows/zero-equation-model/Getter.h b/src/Examples/turbulent-flows/zero-equation-model/Getter.h index 096ae165a..a9a878478 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/Getter.h +++ b/src/Examples/turbulent-flows/zero-equation-model/Getter.h @@ -253,28 +253,30 @@ class TurbulentViscosityGetter< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, const RealType& velocity_z_center = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ center ]; return rho * this->mixingLength * this->mixingLength * - ( ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 - - ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 - ) - * - ( ( velocity_z_north - velocity_z_south ) * hyInverse * 0.5 - - ( velocity_y_up - velocity_y_down ) * hzInverse * 0.5 - ) - * - ( ( velocity_x_up - velocity_x_down ) * hzInverse * 0.5 - - ( velocity_z_east - velocity_z_west ) * hxInverse * 0.5 - ) - + - ( ( velocity_z_east - velocity_z_west ) * hxInverse * 0.5 - - ( velocity_x_up - velocity_x_down ) * hzInverse * 0.5 - ) - * - ( ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 - - ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 - ) - * - ( ( velocity_y_up - velocity_y_down ) * hzInverse * 0.5 - - ( velocity_z_north - velocity_z_south ) *hyInverse * 0.5 + ( + ( ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 + - ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 + ) + * + ( ( velocity_z_north - velocity_z_south ) * hyInverse * 0.5 + - ( velocity_y_up - velocity_y_down ) * hzInverse * 0.5 + ) + * + ( ( velocity_x_up - velocity_x_down ) * hzInverse * 0.5 + - ( velocity_z_east - velocity_z_west ) * hxInverse * 0.5 + ) + + + ( ( velocity_z_east - velocity_z_west ) * hxInverse * 0.5 + - ( velocity_x_up - velocity_x_down ) * hzInverse * 0.5 + ) + * + ( ( velocity_x_north - velocity_x_south ) * hyInverse * 0.5 + - ( velocity_y_east - velocity_y_west ) * hxInverse * 0.5 + ) + * + ( ( velocity_y_up - velocity_y_down ) * hzInverse * 0.5 + - ( velocity_z_north - velocity_z_south ) *hyInverse * 0.5 + ) ); } else return 0; -- GitLab From 5eb0ce305bb47960a481c578869dd65f0de13473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4fer?= Date: Sun, 5 May 2019 21:03:24 +0200 Subject: [PATCH 28/28] code refactoring --- .../Navier-Stokes/AUSM+/AUSMPlusContinuity.h | 20 +++++++++---------- .../Navier-Stokes/AUSM+/AUSMPlusEnergy.h | 8 ++++---- .../AUSM+/AUSMPlusMomentumBase.h | 16 +++++++-------- .../Navier-Stokes/AUSM+/AUSMPlusMomentumX.h | 4 ++-- .../Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h | 2 +- .../flows/RiemannProblemInitialCondition.h | 4 ++-- src/Examples/flows/navierStokesProblem_impl.h | 2 +- .../AUSM+/AUSMPlusContinuity.h | 20 +++++++++---------- .../AUSM+/AUSMPlusEnergy.h | 8 ++++---- .../AUSM+/AUSMPlusMomentumBase.h | 16 +++++++-------- .../AUSM+/AUSMPlusMomentumX.h | 4 ++-- .../AUSM+/AUSMPlusMomentumZ.h | 2 +- .../AUSM+/AUSMPlusTurbulentEnergy.h | 20 +++++++++---------- .../AUSM+/AUSMPlusContinuity.h | 20 +++++++++---------- .../AUSM+/AUSMPlusDisipation.h | 20 +++++++++---------- .../AUSM+/AUSMPlusEnergy.h | 8 ++++---- .../AUSM+/AUSMPlusMomentumBase.h | 16 +++++++-------- .../AUSM+/AUSMPlusMomentumX.h | 4 ++-- .../AUSM+/AUSMPlusMomentumZ.h | 2 +- .../AUSM+/AUSMPlusTurbulentEnergy.h | 20 +++++++++---------- .../KEpsilonDisipationOperatorRightHandSide.h | 6 +++--- .../AUSM+/AUSMPlusContinuity.h | 20 +++++++++---------- .../AUSM+/AUSMPlusDisipation.h | 20 +++++++++---------- .../AUSM+/AUSMPlusEnergy.h | 8 ++++---- .../AUSM+/AUSMPlusMomentumBase.h | 16 +++++++-------- .../AUSM+/AUSMPlusMomentumX.h | 4 ++-- .../AUSM+/AUSMPlusMomentumZ.h | 2 +- .../AUSM+/AUSMPlusTurbulentEnergy.h | 20 +++++++++---------- .../Navier-Stokes/AUSM+/AUSMPlusContinuity.h | 20 +++++++++---------- .../Navier-Stokes/AUSM+/AUSMPlusEnergy.h | 8 ++++---- .../AUSM+/AUSMPlusMomentumBase.h | 16 +++++++-------- .../Navier-Stokes/AUSM+/AUSMPlusMomentumX.h | 4 ++-- .../Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h | 2 +- 33 files changed, 181 insertions(+), 181 deletions(-) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h index 2d92e9dc8..12d85ac85 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h @@ -74,8 +74,8 @@ class AUSMPlusContinuityBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -89,7 +89,7 @@ class AUSMPlusContinuityBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -102,7 +102,7 @@ class AUSMPlusContinuityBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -272,8 +272,8 @@ class AUSMPlusContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operat - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) + hyInverse * ( - this->DensityFlux( u[ north ], u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + this->DensityFlux( u[ south ] , u[ center ], velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->DensityFlux( u[ center ], u[ north ] , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + this->rightHandSide(u, entity, time); @@ -367,12 +367,12 @@ class AUSMPlusContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Operat - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) + hyInverse * ( - this->DensityFlux( u[ north ] , u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + this->DensityFlux( u[ south ] , u[ center ], velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->DensityFlux( u[ center ], u[ north ] , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( - this->DensityFlux( u[ up ] , u[ center ], velocity_z_up , velocity_z_center, pressure_up , pressure_center ) - - this->DensityFlux( u[ center ], u[ down ] , velocity_z_center, velocity_z_down , pressure_center, pressure_down ) + this->DensityFlux( u[ down ] , u[ center ], velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->DensityFlux( u[ center ], u[ up ] , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h index 5914d28bc..f5e04f9da 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h @@ -92,8 +92,8 @@ class AUSMPlusEnergyBase const RealType& LeftEnergy, const RealType& RightEnergy ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -107,7 +107,7 @@ class AUSMPlusEnergyBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -120,7 +120,7 @@ class AUSMPlusEnergyBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h index d2c345833..6c6c34119 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h @@ -73,8 +73,8 @@ class AUSMPlusMomentumBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -92,7 +92,7 @@ class AUSMPlusMomentumBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); PressureSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) * (2.0 - LeftMachNumber ) + 3.0 / 16.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); @@ -109,7 +109,7 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) * (2.0 + RightMachNumber ) - 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); @@ -134,8 +134,8 @@ class AUSMPlusMomentumBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -149,7 +149,7 @@ class AUSMPlusMomentumBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -162,7 +162,7 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h index 1468cf891..24f4c5e78 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h @@ -208,7 +208,7 @@ class AUSMPlusMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operato ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + this->rightHandSide(u, entity, time); @@ -365,7 +365,7 @@ class AUSMPlusMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( this->OtherMomentumFlux( density_down , density_center, velocity_x_down , velocity_x_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) diff --git a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h index fcc6183f2..8915da35c 100644 --- a/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h +++ b/src/Examples/flows/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h @@ -282,7 +282,7 @@ class AUSMPlusMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_z_south , velocity_z_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( this->MainMomentumFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) diff --git a/src/Examples/flows/RiemannProblemInitialCondition.h b/src/Examples/flows/RiemannProblemInitialCondition.h index ff66ff8b7..d3d619c72 100644 --- a/src/Examples/flows/RiemannProblemInitialCondition.h +++ b/src/Examples/flows/RiemannProblemInitialCondition.h @@ -989,11 +989,11 @@ class RiemannProblemInitialCondition 0.0, 0.0, 0.0, //double preNWUVelocityX, double preNWUVelocityY,double preNWUVelocityZ, 0.0, 0.0, 0.0, //double preSWUVelocityX, double preSWUVelocityY,double preSWUVelocityZ, 0.0, 0.0, 0.0, //double preNWDVelocityX, double preNWDVelocityY,double preNWDVelocityZ, - 1.0, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, + 0.1, 0.0, 0.0, //double preSWDVelocityX, double preSWDVelocityY,double preSWDVelocityZ, 0.0, 0.0, 0.0, //double preNEUVelocityX, double preNEUVelocityY,double preNEUVelocityZ, 0.0, 0.0, 0.0, //double preSEUVelocityX, double preSEUVelocityY,double preSEUVelocityZ, 0.0, 0.0, 0.0, //double preNEDVelocityX, double preNEDVelocityY,double preNEDVelocityZ, - 1.0, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ + 0.1, 0.0, 0.0 //double preSEDVelocityX, double preSEDVelocityY,double preSEDVelocityZ ); if(initial == prefix + "1D_Noh") predefinedInitialCondition( 1.4, 0.5, 0.0, 0.0, // double preGamma, double preDiscX, double preDiscY, double preDiscZ, diff --git a/src/Examples/flows/navierStokesProblem_impl.h b/src/Examples/flows/navierStokesProblem_impl.h index 047379d0f..d07de0c20 100644 --- a/src/Examples/flows/navierStokesProblem_impl.h +++ b/src/Examples/flows/navierStokesProblem_impl.h @@ -321,7 +321,7 @@ getExplicitUpdate( const RealType& time, ( *this->conservativeVariables->getMomentum() )[ 2 ], // uRhoVelocityX, ( *this->conservativeVariablesRHS->getMomentum() )[ 2 ] ); //, fuRhoVelocityX ); } - + /**** * Energy equation */ diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h index 2d92e9dc8..1c90c1662 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h @@ -74,8 +74,8 @@ class AUSMPlusContinuityBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -89,7 +89,7 @@ class AUSMPlusContinuityBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -102,7 +102,7 @@ class AUSMPlusContinuityBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -272,8 +272,8 @@ class AUSMPlusContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operat - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) + hyInverse * ( - this->DensityFlux( u[ north ], u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + this->DensityFlux( u[ south ], u[ center ], velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->DensityFlux( u[ center ], u[ north ] , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + this->rightHandSide(u, entity, time); @@ -367,12 +367,12 @@ class AUSMPlusContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Operat - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) + hyInverse * ( - this->DensityFlux( u[ north ] , u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + this->DensityFlux( u[ south ] , u[ center ], velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->DensityFlux( u[ center ], u[ north ] , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( - this->DensityFlux( u[ up ] , u[ center ], velocity_z_up , velocity_z_center, pressure_up , pressure_center ) - - this->DensityFlux( u[ center ], u[ down ] , velocity_z_center, velocity_z_down , pressure_center, pressure_down ) + this->DensityFlux( u[ down ] , u[ center ], velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->DensityFlux( u[ center ], u[ up ] , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h index 52b3c1866..3013e563b 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h @@ -103,8 +103,8 @@ class AUSMPlusEnergyBase const RealType& LeftEnergy, const RealType& RightEnergy ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -118,7 +118,7 @@ class AUSMPlusEnergyBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -131,7 +131,7 @@ class AUSMPlusEnergyBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h index 6ce94d08d..e9b5565d7 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h @@ -84,8 +84,8 @@ class AUSMPlusMomentumBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -103,7 +103,7 @@ class AUSMPlusMomentumBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); PressureSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) * (2.0 - LeftMachNumber ) + 3.0 / 16.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); @@ -120,7 +120,7 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) * (2.0 + RightMachNumber ) - 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); @@ -145,8 +145,8 @@ class AUSMPlusMomentumBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -160,7 +160,7 @@ class AUSMPlusMomentumBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -173,7 +173,7 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h index 1468cf891..24f4c5e78 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h @@ -208,7 +208,7 @@ class AUSMPlusMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operato ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + this->rightHandSide(u, entity, time); @@ -365,7 +365,7 @@ class AUSMPlusMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( this->OtherMomentumFlux( density_down , density_center, velocity_x_down , velocity_x_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h index fcc6183f2..8915da35c 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h @@ -282,7 +282,7 @@ class AUSMPlusMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_z_south , velocity_z_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( this->MainMomentumFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) diff --git a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h index d82503879..9eda7a206 100644 --- a/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/one-equation-model/DifferentialOperators/One-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h @@ -113,8 +113,8 @@ class AUSMPlusTurbulentEnergyBase const RealType& LeftTurbulentEnergy, const RealType& RightTurbulentEnergy ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -128,7 +128,7 @@ class AUSMPlusTurbulentEnergyBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -141,7 +141,7 @@ class AUSMPlusTurbulentEnergyBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -323,8 +323,8 @@ class AUSMPlusTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, O - this->TurbulentEnergyFlux( density_center , density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) + hyInverse * ( - this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ], u[ center ] ) - - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + this->TurbulentEnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) + this->rightHandSide(u, entity, time); @@ -426,12 +426,12 @@ class AUSMPlusTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, O - this->TurbulentEnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) + hyInverse * ( - this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ] , u[ center ] ) - - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + this->TurbulentEnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ] , u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) + hzInverse * ( - this->TurbulentEnergyFlux( density_up , density_center, velocity_z_up , velocity_z_center, pressure_up , pressure_center, u[ up ] , u[ center ]) - - this->TurbulentEnergyFlux( density_center, density_down , velocity_z_center, velocity_z_down , pressure_center, pressure_down , u[ center ], u[ down ] ) + this->TurbulentEnergyFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ] , u[ center ]) + - this->TurbulentEnergyFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h index 2d92e9dc8..1c90c1662 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h @@ -74,8 +74,8 @@ class AUSMPlusContinuityBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -89,7 +89,7 @@ class AUSMPlusContinuityBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -102,7 +102,7 @@ class AUSMPlusContinuityBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -272,8 +272,8 @@ class AUSMPlusContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operat - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) + hyInverse * ( - this->DensityFlux( u[ north ], u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + this->DensityFlux( u[ south ], u[ center ], velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->DensityFlux( u[ center ], u[ north ] , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + this->rightHandSide(u, entity, time); @@ -367,12 +367,12 @@ class AUSMPlusContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Operat - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) + hyInverse * ( - this->DensityFlux( u[ north ] , u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + this->DensityFlux( u[ south ] , u[ center ], velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->DensityFlux( u[ center ], u[ north ] , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( - this->DensityFlux( u[ up ] , u[ center ], velocity_z_up , velocity_z_center, pressure_up , pressure_center ) - - this->DensityFlux( u[ center ], u[ down ] , velocity_z_center, velocity_z_down , pressure_center, pressure_down ) + this->DensityFlux( u[ down ] , u[ center ], velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->DensityFlux( u[ center ], u[ up ] , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h index d6ca3d7fa..832e71d24 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h @@ -118,8 +118,8 @@ class AUSMPlusDisipationBase const RealType& LeftDisipation, const RealType& RightDisipation ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -133,7 +133,7 @@ class AUSMPlusDisipationBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -146,7 +146,7 @@ class AUSMPlusDisipationBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -328,8 +328,8 @@ class AUSMPlusDisipation< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operat - this->DisipationFlux( density_center , density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) + hyInverse * ( - this->DisipationFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ], u[ center ] ) - - this->DisipationFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + this->DisipationFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->DisipationFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) + this->rightHandSide(u, entity, time); @@ -431,12 +431,12 @@ class AUSMPlusDisipation< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Operat - this->DisipationFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) + hyInverse * ( - this->DisipationFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ] , u[ center ] ) - - this->TurbulrntEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + this->DisipationFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ] , u[ center ] ) + - this->DisipationFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) + hzInverse * ( - this->DisipationFlux( density_up , density_center, velocity_z_up , velocity_z_center, pressure_up , pressure_center, u[ up ] , u[ center ]) - - this->DisipationFlux( density_center, density_down , velocity_z_center, velocity_z_down , pressure_center, pressure_down , u[ center ], u[ down ] ) + this->DisipationFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ] , u[ center ]) + - this->DisipationFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h index 52b3c1866..3013e563b 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h @@ -103,8 +103,8 @@ class AUSMPlusEnergyBase const RealType& LeftEnergy, const RealType& RightEnergy ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -118,7 +118,7 @@ class AUSMPlusEnergyBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -131,7 +131,7 @@ class AUSMPlusEnergyBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h index 6ce94d08d..e9b5565d7 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h @@ -84,8 +84,8 @@ class AUSMPlusMomentumBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -103,7 +103,7 @@ class AUSMPlusMomentumBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); PressureSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) * (2.0 - LeftMachNumber ) + 3.0 / 16.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); @@ -120,7 +120,7 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) * (2.0 + RightMachNumber ) - 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); @@ -145,8 +145,8 @@ class AUSMPlusMomentumBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -160,7 +160,7 @@ class AUSMPlusMomentumBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -173,7 +173,7 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h index 1468cf891..24f4c5e78 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h @@ -208,7 +208,7 @@ class AUSMPlusMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operato ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + this->rightHandSide(u, entity, time); @@ -365,7 +365,7 @@ class AUSMPlusMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( this->OtherMomentumFlux( density_down , density_center, velocity_x_down , velocity_x_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h index fcc6183f2..8915da35c 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h @@ -282,7 +282,7 @@ class AUSMPlusMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_z_south , velocity_z_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( this->MainMomentumFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h index dedb7e7ac..3c5f77bb4 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h @@ -103,8 +103,8 @@ class AUSMPlusTurbulentEnergyBase const RealType& LeftTurbulentEnergy, const RealType& RightTurbulentEnergy ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -118,7 +118,7 @@ class AUSMPlusTurbulentEnergyBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -131,7 +131,7 @@ class AUSMPlusTurbulentEnergyBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -313,8 +313,8 @@ class AUSMPlusTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, O - this->TurbulentEnergyFlux( density_center , density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) + hyInverse * ( - this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ], u[ center ] ) - - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + this->TurbulentEnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) + this->rightHandSide(u, entity, time); @@ -416,12 +416,12 @@ class AUSMPlusTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, O - this->TurbulentEnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) + hyInverse * ( - this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ] , u[ center ] ) - - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + this->TurbulentEnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ] , u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) + hzInverse * ( - this->TurbulentEnergyFlux( density_up , density_center, velocity_z_up , velocity_z_center, pressure_up , pressure_center, u[ up ] , u[ center ]) - - this->TurbulentEnergyFlux( density_center, density_down , velocity_z_center, velocity_z_down , pressure_center, pressure_down , u[ center ], u[ down ] ) + this->TurbulentEnergyFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ] , u[ center ]) + - this->TurbulentEnergyFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h index 26fddb13d..05be9d8e0 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h +++ b/src/Examples/turbulent-flows/two-equation-model/KEPsilon-model/DifferentialOperatorsRightHandSide/KEPsilonRightHandSide/KEpsilonDisipationOperatorRightHandSide.h @@ -177,7 +177,7 @@ class KEpsilonDisipationRightHandSide< Meshes::Grid< 1, MeshReal, Device, MeshIn const RealType& velocity_x_west = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ west ]; const RealType& velocity_x_center = this->velocity.template getData< TNL::Devices::Host >()[ 0 ].template getData< DeviceType >()[ center ]; - if( ! turbulentEnergy_center == 0.0 ) + if( ! ( turbulentEnergy_center == 0.0 ) ) return this->dynamicalViscosity * ( disipation_east - 2 * disipation_center + disipation_west ) @@ -309,7 +309,7 @@ class KEpsilonDisipationRightHandSide< Meshes::Grid< 2, MeshReal, Device, MeshIn const RealType& velocity_y_northEast = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northEast ]; const RealType& velocity_y_northWest = this->velocity.template getData< TNL::Devices::Host >()[ 1 ].template getData< DeviceType >()[ northWest ]; - if( ! turbulentEnergy_center == 0.0 ) + if( ! ( turbulentEnergy_center == 0.0 ) ) return this->dynamicalViscosity * ( disipation_east - 2 * disipation_center + disipation_west ) @@ -527,7 +527,7 @@ class KEpsilonDisipationRightHandSide< Meshes::Grid< 3, MeshReal, Device, MeshIn const RealType& velocity_z_downNorth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downNorth ]; const RealType& velocity_z_downSouth = this->velocity.template getData< TNL::Devices::Host >()[ 2 ].template getData< DeviceType >()[ downSouth ]; - if( ! turbulentEnergy_center == 0.0 ) + if( ! ( turbulentEnergy_center == 0.0 ) ) return this->dynamicalViscosity * ( disipation_east - 2 * disipation_center + disipation_west ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h index 2d92e9dc8..9ba702004 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusContinuity.h @@ -74,8 +74,8 @@ class AUSMPlusContinuityBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -89,7 +89,7 @@ class AUSMPlusContinuityBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -102,7 +102,7 @@ class AUSMPlusContinuityBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -272,8 +272,8 @@ class AUSMPlusContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operat - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) + hyInverse * ( - this->DensityFlux( u[ north ], u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + this->DensityFlux( u[ south ], u[ center ], velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->DensityFlux( u[ center ], u[ north ] , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + this->rightHandSide(u, entity, time); @@ -367,12 +367,12 @@ class AUSMPlusContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Operat - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) + hyInverse * ( - this->DensityFlux( u[ north ] , u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + this->DensityFlux( u[ south ] , u[ center ], velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->DensityFlux( u[ center ], u[ north ] , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( - this->DensityFlux( u[ up ] , u[ center ], velocity_z_up , velocity_z_center, pressure_up , pressure_center ) - - this->DensityFlux( u[ center ], u[ down ] , velocity_z_center, velocity_z_down , pressure_center, pressure_down ) + this->DensityFlux( u[ down ] , u[ center ], velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->DensityFlux( u[ center ], u[ up ] , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h index 09a4469c4..8c6a27150 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusDisipation.h @@ -118,8 +118,8 @@ class AUSMPlusDisipationBase const RealType& LeftDisipation, const RealType& RightDisipation ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -133,7 +133,7 @@ class AUSMPlusDisipationBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -146,7 +146,7 @@ class AUSMPlusDisipationBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -328,8 +328,8 @@ class AUSMPlusDisipation< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operat - this->DisipationFlux( density_center , density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) + hyInverse * ( - this->DisipationFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ], u[ center ] ) - - this->DisipationFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + this->DisipationFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->DisipationFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) + this->rightHandSide(u, entity, time); @@ -431,12 +431,12 @@ class AUSMPlusDisipation< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Operat - this->DisipationFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) + hyInverse * ( - this->DisipationFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ] , u[ center ] ) - - this->TurbulrntEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + this->DisipationFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ] , u[ center ] ) + - this->DisipationFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) + hzInverse * ( - this->DisipationFlux( density_up , density_center, velocity_z_up , velocity_z_center, pressure_up , pressure_center, u[ up ] , u[ center ]) - - this->DisipationFlux( density_center, density_down , velocity_z_center, velocity_z_down , pressure_center, pressure_down , u[ center ], u[ down ] ) + this->DisipationFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ] , u[ center ]) + - this->DisipationFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h index 31787bb8d..be20ec9dd 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusEnergy.h @@ -103,8 +103,8 @@ class AUSMPlusEnergyBase const RealType& LeftEnergy, const RealType& RightEnergy ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -118,7 +118,7 @@ class AUSMPlusEnergyBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -131,7 +131,7 @@ class AUSMPlusEnergyBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h index 74fe948cd..a049568ca 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumBase.h @@ -84,8 +84,8 @@ class AUSMPlusMomentumBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -103,7 +103,7 @@ class AUSMPlusMomentumBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); PressureSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) * (2.0 - LeftMachNumber ) + 3.0 / 16.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); @@ -120,7 +120,7 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) * (2.0 + RightMachNumber ) - 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); @@ -145,8 +145,8 @@ class AUSMPlusMomentumBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -160,7 +160,7 @@ class AUSMPlusMomentumBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -173,7 +173,7 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h index 1468cf891..24f4c5e78 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumX.h @@ -208,7 +208,7 @@ class AUSMPlusMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operato ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + this->rightHandSide(u, entity, time); @@ -365,7 +365,7 @@ class AUSMPlusMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( this->OtherMomentumFlux( density_down , density_center, velocity_x_down , velocity_x_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h index fcc6183f2..8915da35c 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusMomentumZ.h @@ -282,7 +282,7 @@ class AUSMPlusMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_z_south , velocity_z_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( this->MainMomentumFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) diff --git a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h index 66933348b..034e5ab6f 100644 --- a/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h +++ b/src/Examples/turbulent-flows/two-equation-model/KOmega-model/DifferentialOperators/Two-Equation-turbulence-model/AUSM+/AUSMPlusTurbulentEnergy.h @@ -112,8 +112,8 @@ class AUSMPlusTurbulentEnergyBase const RealType& LeftTurbulentEnergy, const RealType& RightTurbulentEnergy ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -127,7 +127,7 @@ class AUSMPlusTurbulentEnergyBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -140,7 +140,7 @@ class AUSMPlusTurbulentEnergyBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -322,8 +322,8 @@ class AUSMPlusTurbulentEnergy< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, O - this->TurbulentEnergyFlux( density_center , density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) + hyInverse * ( - this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ], u[ center ] ) - - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + this->TurbulentEnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ], u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) + this->rightHandSide(u, entity, time); @@ -425,12 +425,12 @@ class AUSMPlusTurbulentEnergy< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, O - this->TurbulentEnergyFlux( density_center, density_east , velocity_x_center, velocity_x_east , pressure_center, pressure_east , u[ center ], u[ east ] ) ) + hyInverse * ( - this->TurbulentEnergyFlux( density_north , density_center, velocity_y_north , velocity_y_center, pressure_north , pressure_center, u[ north ] , u[ center ] ) - - this->TurbulentEnergyFlux( density_center, density_south , velocity_y_center, velocity_y_south , pressure_center, pressure_south , u[ center ], u[ south ] ) + this->TurbulentEnergyFlux( density_south , density_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center, u[ south ] , u[ center ] ) + - this->TurbulentEnergyFlux( density_center, density_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north , u[ center ], u[ north ] ) ) + hzInverse * ( - this->TurbulentEnergyFlux( density_up , density_center, velocity_z_up , velocity_z_center, pressure_up , pressure_center, u[ up ] , u[ center ]) - - this->TurbulentEnergyFlux( density_center, density_down , velocity_z_center, velocity_z_down , pressure_center, pressure_down , u[ center ], u[ down ] ) + this->TurbulentEnergyFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center, u[ down ] , u[ center ]) + - this->TurbulentEnergyFlux( density_center, density_up , velocity_z_center, velocity_z_up , pressure_center, pressure_up , u[ center ], u[ up ] ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h index 2d92e9dc8..1c90c1662 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusContinuity.h @@ -74,8 +74,8 @@ class AUSMPlusContinuityBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -89,7 +89,7 @@ class AUSMPlusContinuityBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -102,7 +102,7 @@ class AUSMPlusContinuityBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else @@ -272,8 +272,8 @@ class AUSMPlusContinuity< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operat - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) + hyInverse * ( - this->DensityFlux( u[ north ], u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + this->DensityFlux( u[ south ], u[ center ], velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->DensityFlux( u[ center ], u[ north ] , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + this->rightHandSide(u, entity, time); @@ -367,12 +367,12 @@ class AUSMPlusContinuity< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, Operat - this->DensityFlux( u[ center ], u[ east ] , velocity_x_center, velocity_x_east , pressure_center, pressure_east ) ) + hyInverse * ( - this->DensityFlux( u[ north ] , u[ center ], velocity_y_north , velocity_y_center, pressure_north , pressure_center ) - - this->DensityFlux( u[ center ], u[ south ] , velocity_y_center, velocity_y_south , pressure_center, pressure_south ) + this->DensityFlux( u[ south ] , u[ center ], velocity_y_south , velocity_y_center, pressure_south , pressure_center ) + - this->DensityFlux( u[ center ], u[ north ] , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( - this->DensityFlux( u[ up ] , u[ center ], velocity_z_up , velocity_z_center, pressure_up , pressure_center ) - - this->DensityFlux( u[ center ], u[ down ] , velocity_z_center, velocity_z_down , pressure_center, pressure_down ) + this->DensityFlux( u[ down ] , u[ center ], velocity_z_down , velocity_z_center, pressure_down , pressure_center ) + - this->DensityFlux( u[ center ], u[ up ] , velocity_z_center, velocity_z_up , pressure_center, pressure_up ) ) + this->rightHandSide(u, entity, time); diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h index a0f4c7ea9..f8a722d39 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusEnergy.h @@ -97,8 +97,8 @@ class AUSMPlusEnergyBase const RealType& LeftEnergy, const RealType& RightEnergy ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -112,7 +112,7 @@ class AUSMPlusEnergyBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -125,7 +125,7 @@ class AUSMPlusEnergyBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h index 2cbf6ad16..161a6f9bc 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumBase.h @@ -78,8 +78,8 @@ class AUSMPlusMomentumBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -97,7 +97,7 @@ class AUSMPlusMomentumBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); PressureSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) * (2.0 - LeftMachNumber ) + 3.0 / 16.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); @@ -114,7 +114,7 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); PressureSplitingMinus = 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) * (2.0 + RightMachNumber ) - 3.0 / 16.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); @@ -139,8 +139,8 @@ class AUSMPlusMomentumBase const RealType& LeftPressure, const RealType& RightPressure ) const { - const RealType& LeftSpeedOfSound = std::sqrt( this->gamma * LeftPressure / LeftDensity ); - const RealType& RightSpeedOfSound = std::sqrt( this->gamma * RightPressure / RightDensity ); + const RealType& LeftSpeedOfSound = std::sqrt( std::abs( this->gamma * LeftPressure / LeftDensity ) ); + const RealType& RightSpeedOfSound = std::sqrt( std::abs( this->gamma * RightPressure / RightDensity ) ); const RealType& BorderSpeedOfSound = 0.5 * ( LeftSpeedOfSound + RightSpeedOfSound ); const RealType& LeftMachNumber = LeftVelocity / BorderSpeedOfSound; const RealType& RightMachNumber = RightVelocity / BorderSpeedOfSound; @@ -154,7 +154,7 @@ class AUSMPlusMomentumBase } else if ( LeftMachNumber <= 1.0 ) { - MachSplitingPlus = 1.0 / 2.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + MachSplitingPlus = 1.0 / 4.0 * ( LeftMachNumber + 1.0 ) * ( LeftMachNumber + 1.0 ) + 1.0 / 8.0 * ( LeftMachNumber * LeftMachNumber - 1.0 ) * ( LeftMachNumber * LeftMachNumber - 1.0 ); } else @@ -167,7 +167,7 @@ class AUSMPlusMomentumBase } else if ( RightMachNumber <= 1.0 ) { - MachSplitingMinus = - 1.0 / 2.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) + MachSplitingMinus = - 1.0 / 4.0 * ( RightMachNumber - 1.0 ) * ( RightMachNumber - 1.0 ) - 1.0 / 8.0 * ( RightMachNumber * RightMachNumber - 1.0 ) * ( RightMachNumber * RightMachNumber - 1.0 ); } else diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h index 1468cf891..24f4c5e78 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumX.h @@ -208,7 +208,7 @@ class AUSMPlusMomentumX< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, Operato ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + this->rightHandSide(u, entity, time); @@ -365,7 +365,7 @@ class AUSMPlusMomentumX< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_x_south , velocity_x_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_x_center, velocity_x_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( this->OtherMomentumFlux( density_down , density_center, velocity_x_down , velocity_x_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) diff --git a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h index fcc6183f2..8915da35c 100644 --- a/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h +++ b/src/Examples/turbulent-flows/zero-equation-model/DifferentialOperators/Navier-Stokes/AUSM+/AUSMPlusMomentumZ.h @@ -282,7 +282,7 @@ class AUSMPlusMomentumZ< Meshes::Grid< 3,MeshReal, Device, MeshIndex >, Operator ) + hyInverse * ( this->OtherMomentumFlux( density_south , density_center, velocity_z_south , velocity_z_center, velocity_y_south , velocity_y_center, pressure_south , pressure_center ) - - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_south , pressure_center, pressure_north ) + - this->OtherMomentumFlux( density_center, density_north , velocity_z_center, velocity_z_north , velocity_y_center, velocity_y_north , pressure_center, pressure_north ) ) + hzInverse * ( this->MainMomentumFlux( density_down , density_center, velocity_z_down , velocity_z_center, pressure_down , pressure_center ) -- GitLab